Skip to content

Commit 3609855

Browse files
ebiggersJaegeuk Kim
authored andcommitted
f2fs: separate f2fs i_flags from fs_flags and ext4 i_flags
f2fs copied all the on-disk i_flags from ext4, and along with it the assumption that the on-disk i_flags are the same as the bits used by FS_IOC_GETFLAGS and FS_IOC_SETFLAGS. This is problematic because reserving an on-disk inode flag in either filesystem's i_flags or in these ioctls effectively reserves it in all the other places too. In fact, most of the "f2fs i_flags" are not used by f2fs at all. Fix this by separating f2fs's i_flags from the ioctl bits and ext4's i_flags. In the process, un-reserve all "f2fs i_flags" that aren't actually supported by f2fs. This included various flags that were not settable at all, as well as various flags that were settable by FS_IOC_SETFLAGS but didn't actually do anything. There's a slight chance we'll need to add some flag(s) back to FS_IOC_SETFLAGS in order to avoid breaking users who expect f2fs to accept some random flag(s). But hopefully such users don't exist. Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 176ef3c commit 3609855

2 files changed

Lines changed: 163 additions & 118 deletions

File tree

‎fs/f2fs/f2fs.h‎

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,57 +2334,23 @@ static inline void f2fs_change_bit(unsigned int nr, char *addr)
23342334
}
23352335

23362336
/*
2337-
* Inode flags
2337+
* On-disk inode flags (f2fs_inode::i_flags)
23382338
*/
2339-
#define F2FS_SECRM_FL 0x00000001 /* Secure deletion */
2340-
#define F2FS_UNRM_FL 0x00000002 /* Undelete */
2341-
#define F2FS_COMPR_FL 0x00000004 /* Compress file */
23422339
#define F2FS_SYNC_FL 0x00000008 /* Synchronous updates */
23432340
#define F2FS_IMMUTABLE_FL 0x00000010 /* Immutable file */
23442341
#define F2FS_APPEND_FL 0x00000020 /* writes to file may only append */
23452342
#define F2FS_NODUMP_FL 0x00000040 /* do not dump file */
23462343
#define F2FS_NOATIME_FL 0x00000080 /* do not update atime */
2347-
/* Reserved for compression usage... */
2348-
#define F2FS_DIRTY_FL 0x00000100
2349-
#define F2FS_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
2350-
#define F2FS_NOCOMPR_FL 0x00000400 /* Don't compress */
2351-
#define F2FS_ENCRYPT_FL 0x00000800 /* encrypted file */
2352-
/* End compression flags --- maybe not all used */
23532344
#define F2FS_INDEX_FL 0x00001000 /* hash-indexed directory */
2354-
#define F2FS_IMAGIC_FL 0x00002000 /* AFS directory */
2355-
#define F2FS_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
2356-
#define F2FS_NOTAIL_FL 0x00008000 /* file tail should not be merged */
23572345
#define F2FS_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
2358-
#define F2FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
2359-
#define F2FS_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
2360-
#define F2FS_EXTENTS_FL 0x00080000 /* Inode uses extents */
2361-
#define F2FS_EA_INODE_FL 0x00200000 /* Inode used for large EA */
2362-
#define F2FS_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
2363-
#define F2FS_NOCOW_FL 0x00800000 /* Do not cow file */
2364-
#define F2FS_INLINE_DATA_FL 0x10000000 /* Inode has inline data. */
23652346
#define F2FS_PROJINHERIT_FL 0x20000000 /* Create with parents projid */
2366-
#define F2FS_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
2367-
2368-
#define F2FS_FL_USER_VISIBLE 0x30CBDFFF /* User visible flags */
2369-
#define F2FS_FL_USER_MODIFIABLE 0x204BC0FF /* User modifiable flags */
2370-
2371-
/* Flags we can manipulate with through F2FS_IOC_FSSETXATTR */
2372-
#define F2FS_FL_XFLAG_VISIBLE (F2FS_SYNC_FL | \
2373-
F2FS_IMMUTABLE_FL | \
2374-
F2FS_APPEND_FL | \
2375-
F2FS_NODUMP_FL | \
2376-
F2FS_NOATIME_FL | \
2377-
F2FS_PROJINHERIT_FL)
23782347

23792348
/* Flags that should be inherited by new inodes from their parent. */
2380-
#define F2FS_FL_INHERITED (F2FS_SECRM_FL | F2FS_UNRM_FL | F2FS_COMPR_FL |\
2381-
F2FS_SYNC_FL | F2FS_NODUMP_FL | F2FS_NOATIME_FL |\
2382-
F2FS_NOCOMPR_FL | F2FS_JOURNAL_DATA_FL |\
2383-
F2FS_NOTAIL_FL | F2FS_DIRSYNC_FL |\
2384-
F2FS_PROJINHERIT_FL)
2349+
#define F2FS_FL_INHERITED (F2FS_SYNC_FL | F2FS_NODUMP_FL | F2FS_NOATIME_FL | \
2350+
F2FS_DIRSYNC_FL | F2FS_PROJINHERIT_FL)
23852351

23862352
/* Flags that are appropriate for regular files (all but dir-specific ones). */
2387-
#define F2FS_REG_FLMASK (~(F2FS_DIRSYNC_FL | F2FS_TOPDIR_FL))
2353+
#define F2FS_REG_FLMASK (~F2FS_DIRSYNC_FL)
23882354

23892355
/* Flags that are appropriate for non-directories/regular files. */
23902356
#define F2FS_OTHER_FLMASK (F2FS_NODUMP_FL | F2FS_NOATIME_FL)

0 commit comments

Comments
 (0)