File System IOCTLs: Three new IOCTLS were added for SPIFFS, two of which were duplicates.

This commit is contained in:
Gregory Nutt 2018-09-27 12:25:23 -06:00
parent 65ef3acf70
commit 1273f727c0
3 changed files with 27 additions and 27 deletions

View File

@ -142,12 +142,16 @@ The file system supports to ioctls:
FIOC_REFORMAT: Will force the flash to be erased and a fresh, empty
NXFFS file system to be written on it.
FIOC_OPTIMIZE: Will force immediate repacking of the file system. This
will increase the amount of wear on the FLASH if you use this!
will avoid the delays to repack the file system in the emergency case
when all of the FLASH memory has been used. Instead, you can defer
the garbage collection to time when the system is not busy. Calling
this function on a thrashing file system will increase the amount of
wear on the FLASH if you use this frequently!
Things to Do
============
- The statfs() implementation is minimal. It whould have some calcuation
- The statfs() implementation is minimal. It should have some calculation
of the f_bfree, f_bavail, f_files, f_ffree return values.
- There are too many allocs and frees. More structures may need to be
pre-allocated.
@ -169,17 +173,20 @@ Things to Do
front of the device, the level of wear on the blocks at the end of the
FLASH increases.
- When the time comes to reorganization the FLASH, the system may be
inavailable for a long time. That is a bad behavior. What is needed,
unavailable for a long time. That is a bad behavior. What is needed,
I think, is a garbage collection task that runs periodically so that
when the big reorganizaiton event occurs, most of the work is already
done. That garbarge collection should search for valid blocks that no
when the big reorganization event occurs, most of the work is already
done. That garbage collection should search for valid blocks that no
longer contain valid data. It should pre-erase them, put them in
a good but empty state... all ready for file system re-organization.
NOTE: There is the FIOC_OPTIMIZE IOCTL command that can be used by an
application for force garbage collection when the system is not busy.
If used judiciously by the application, this can eliminate the problem.
- And worse, when NXFSS reorganization the FLASH a power cycle can
damage the file system content if it happens at the wrong time.
- The current design does not permit re-opening of files for write access
unless the file is truncated to zero length. This effectively prohibits
implementation of a proper turncate() method which should alter the
size of a previously written file. There is some fragmentray logic in
implementation of a proper truncate() method which should alter the
size of a previously written file. There is some fragmentary logic in
place but even this is conditioned out with __NO_TRUNCATE_SUPPORT__.

View File

@ -954,7 +954,7 @@ static int spiffs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* OUT: None
*/
case BIOC_CHECK:
case FIOC_INTEGRITY:
{
ret = spiffs_consistency_check(fs);
}
@ -965,7 +965,7 @@ static int spiffs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* OUT: None
*/
case BIOC_FORMAT:
case FIOC_REFORMAT:
{
/* Check if the MTD driver supports the MTDIOC_BULKERASE command */
@ -995,7 +995,7 @@ static int spiffs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* OUT: None
*/
case BIOC_GC:
case FIOC_OPTIMIZE:
{
ret = spiffs_gc_check(fs, (size_t)arg);
}

View File

@ -136,7 +136,8 @@
#define FIOC_REFORMAT _FIOC(0x0002) /* IN: None
* OUT: None
*/
#define FIOC_OPTIMIZE _FIOC(0x0003) /* IN: None
#define FIOC_OPTIMIZE _FIOC(0x0003) /* IN: The number of bytes to recover
* (ignored on most file systems)
* OUT: None
*/
#define FIOC_FILENAME _FIOC(0x0004) /* IN: FAR const char ** pointer
@ -144,17 +145,21 @@
* (Guaranteed to persist while the file
* is open).
*/
#define FIOC_INTEGRITY _FIOC(0x0005) /* Run a consistency check on the
* file system media.
* IN: None
* OUT: None */
#define FIONREAD _FIOC(0x0005) /* IN: Location to return value (int *)
#define FIONREAD _FIOC(0x0006) /* IN: Location to return value (int *)
* OUT: Bytes readable from this fd
*/
#define FIONWRITE _FIOC(0x0006) /* IN: Location to return value (int *)
#define FIONWRITE _FIOC(0x0007) /* IN: Location to return value (int *)
* OUT: Number bytes in send queue
*/
#define FIONSPACE _FIOC(0x0007) /* IN: Location to return value (int *)
#define FIONSPACE _FIOC(0x0008) /* IN: Location to return value (int *)
* OUT: Free space in send queue.
*/
#define FIONUSERFS _FIOC(0x0008) /* IN: Pointer to struct usefs_config_s
#define FIONUSERFS _FIOC(0x0009) /* IN: Pointer to struct usefs_config_s
* holding userfs configuration.
* OUT: Instance number is returned on
* success.
@ -249,18 +254,6 @@
* to return geometry.
* OUT: Data return in user-provided
* buffer. */
#define BIOC_CHECK _BIOC(0x000d) /* Run a consistency check on the
* file system media.
* IN: None
* OUT: None */
#define BIOC_FORMAT _BIOC(0x000e) /* Force reformatting of media. All
* data will be lost.
* IN: None
* OUT: None */
#define BIOC_GC _BIOC(0x000f) /* Run garbage collection.
* IN: On entry holds the number
* of bytes to be recovered.
* OUT: None */
/* NuttX MTD driver ioctl definitions ***************************************/