f2fs: introduce lost+found feature
cover f2fs: introduce lost+found feature
This patchset introduces lost+found feature in f2fs. If the feature is enabled, f2fs should avoid to encrypting root directory.
For more information, please check the mail "f2fs-tools: introduce lost+ found feature".
Thanks,
Sheng
Sheng Yong (2):
f2fs: clean up f2fs_sb_has_xxx functions
f2fs: introduce lost+found feature
fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 53 +++++++++++++++-------------------------------------- fs/f2fs/file.c | 6 +++--- fs/f2fs/segment.c | 4 ++-- fs/f2fs/super.c | 26 +++++++++++++++++++------- fs/f2fs/sysfs.c | 4 ++-- 6 files changed, 42 insertions(+), 53 deletions(-)
Signature · 6 lines
2.11.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
RFC PATCH 1/2 f2fs: clean up f2fs_sb_has_xxx functions
This patch introduces F2FS_FEATURE_FUNCS to clean up the definitions of different f2fs_sb_has_xxx functions.
--- fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 51 +++++++++++++-------------------------------------- fs/f2fs/file.c | 6 +++--- fs/f2fs/segment.c | 4 ++-- fs/f2fs/super.c | 14 +++++++------- fs/f2fs/sysfs.c | 4 ++-- 6 files changed, 28 insertions(+), 53 deletions(-)
fs/f2fs/data.c +1 -1
@@ -196,7 +196,7 @@ static inline void __submit_bio(struct f2fs_sb_info *sbi,if (!is_read_io (bio_op (bio))) {unsigned int start; -if (f2fs_sb_mounted_blkzoned (sbi->sb) && +if (f2fs_sb_has_blkzoned (sbi->sb) && current->plug && (type ==DATA || type ==NODE ))blk_finish_plug (current->plug);
fs/f2fs/f2fs.h +13 -38
65 lines not on this page · raw message
fs/f2fs/file.c +3 -3
@@ -1938,7 +1938,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) {struct inode *inode =file_inode (filp); -if (!f2fs_sb_has_crypto (inode->i_sb)) +if (!f2fs_sb_has_encrypt (inode->i_sb))return -EOPNOTSUPP ;f2fs_update_time (F2FS_I_SB (inode),REQ_TIME );
@@ -1948,7 +1948,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)static int f2fs_ioc_get_encryption_policy (struct file *filp,unsigned long arg) { -if (!f2fs_sb_has_crypto (file_inode (filp)->i_sb)) +if (!f2fs_sb_has_encrypt (file_inode (filp)->i_sb))return -EOPNOTSUPP ;return fscrypt_ioctl_get_policy (filp, (void __user *)arg); }
@@ -1959,7 +1959,7 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg)struct f2fs_sb_info *sbi =F2FS_I_SB (inode);int err; -if (!f2fs_sb_has_crypto (inode->i_sb)) +if (!f2fs_sb_has_encrypt (inode->i_sb))return -EOPNOTSUPP ;if (uuid_is_nonzero (sbi->raw_super->encrypt_pw_salt))
fs/f2fs/segment.c +2 -2
@@ -1485,7 +1485,7 @@ static int __issue_discard_async(struct f2fs_sb_info *sbi, struct block_device *bdev, block_t blkstart, block_t blklen) { #ifdef CONFIG_BLK_DEV_ZONED - if (f2fs_sb_mounted_blkzoned(sbi->sb) && + if (f2fs_sb_has_blkzoned(sbi->sb) && bdev_zoned_model(bdev) != BLK_ZONED_NONE) return __f2fs_issue_discard_zone(sbi, bdev, blkstart, blklen); #endif
@@ -1683,7 +1683,7 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc) sbi->blocks_per_seg, cur_pos); len = next_pos - cur_pos; -if (f2fs_sb_mounted_blkzoned (sbi->sb) || +if (f2fs_sb_has_blkzoned (sbi->sb) || (force && len < cpc->trim_minlen)) goto skip;
fs/f2fs/super.c +7 -7
@@ -403,14 +403,14 @@ static int parse_options(struct super_block *sb, char *options) q =bdev_get_queue (sb->s_bdev);if (blk_queue_discard (q)) {set_opt (sbi,DISCARD ); - }else if (!f2fs_sb_mounted_blkzoned (sb)) { + }else if (!f2fs_sb_has_blkzoned (sb)) {f2fs_msg (sb,KERN_WARNING ,"mounting with \"discard\" option, but " "the device does not support discard" ); }break ;case Opt_nodiscard: -if (f2fs_sb_mounted_blkzoned (sb)) { +if (f2fs_sb_has_blkzoned (sb)) {f2fs_msg (sb,KERN_WARNING ,"discard is required for zoned block devices" );return -EINVAL ;
@@ -559,7 +559,7 @@ static int parse_options(struct super_block *sb, char *options)return -ENOMEM ;if (strlen (name) ==8 && !strncmp (name,"adaptive" ,8 )) { -if (f2fs_sb_mounted_blkzoned (sb)) { +if (f2fs_sb_has_blkzoned (sb)) {f2fs_msg (sb,KERN_WARNING ,"adaptive mode is not allowed with " "zoned block device feature" );
@@ -1243,7 +1243,7 @@ static void default_options(struct f2fs_sb_info *sbi)set_opt (sbi,NOHEAP ); sbi->sb->s_flags |=SB_LAZYTIME ;set_opt (sbi,FLUSH_MERGE ); -if (f2fs_sb_mounted_blkzoned (sbi->sb)) { +if (f2fs_sb_has_blkzoned (sbi->sb)) {set_opt_mode (sbi,F2FS_MOUNT_LFS );set_opt (sbi,DISCARD ); }else {
@@ -2206,7 +2206,7 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)unsigned int n =0 ;int err = -EIO ; -if (!f2fs_sb_mounted_blkzoned (sbi->sb)) +if (!f2fs_sb_has_blkzoned (sbi->sb))return 0 ; if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
@@ -2413,7 +2413,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)#ifdef CONFIG_BLK_DEV_ZONED if (bdev_zoned_model (FDEV (i).bdev) ==BLK_ZONED_HM && - !f2fs_sb_mounted_blkzoned (sbi->sb)) { + !f2fs_sb_has_blkzoned (sbi->sb)) {f2fs_msg (sbi->sb,KERN_ERR ,"Zoned block device feature not enabled\n" );return -EINVAL ;
@@ -2508,7 +2508,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)* devices, but mandatory for host-managed zoned block devices. */ #ifndef CONFIG_BLK_DEV_ZONED -if (f2fs_sb_mounted_blkzoned (sb)) { +if (f2fs_sb_has_blkzoned (sb)) {f2fs_msg (sb,KERN_ERR ,"Zoned block device support is not enabled\n" ); err = -EOPNOTSUPP ;
fs/f2fs/sysfs.c +2 -2
@@ -92,10 +92,10 @@ static ssize_t features_show(struct f2fs_attr *a,if (!sb->s_bdev->bd_part)return snprintf (buf,PAGE_SIZE ,"0\n" ); -if (f2fs_sb_has_crypto (sb)) +if (f2fs_sb_has_encrypt (sb)) len +=snprintf (buf,PAGE_SIZE - len,"%s" ,"encryption" ); -if (f2fs_sb_mounted_blkzoned (sb)) +if (f2fs_sb_has_blkzoned (sb)) len +=snprintf (buf + len,PAGE_SIZE - len,"%s%s" , len ?", " :"" ,"blkzoned" );if (f2fs_sb_has_extra_attr (sb))
Signature · 6 lines
2.11.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [RFC PATCH 1/2] f2fs: clean up f2fs_sb_has_xxx functions
Quoted 4 lines · Sheng Yong
This patch introduces
F2FS_FEATURE_FUNCSto clean up the definitions of differentf2fs_sb_has_xxxfunctions.Signed-off-by Sheng Yong <[email protected]>
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
RFC PATCH 2/2 f2fs: introduce lost+found feature
In reply to Sheng YongIntroduce lost+found feature. The lost+found is a directory which saves unreachable files. If f2fsck finds a file which has no parent, or the parent is removed by f2fsck, the file will be placed in lost+found directory.
According fscrypt policy, lost+found could not be encrypted. As a result, the root directory cannot be encrypted. So if lost+found feature is enabled, let's avoid to encrypt root directory.
--- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/super.c | 12 ++++++++++++ 2 files changed, 14 insertions(+)
fs/f2fs/f2fs.h +2 -0
@@ -125,6 +125,7 @@ struct f2fs_mount_info {#define F2FS_FEATURE_FLEXIBLE_INLINE_XATTR 0x0040#define F2FS_FEATURE_QUOTA_INO 0x0080#define F2FS_FEATURE_INODE_CRTIME 0x0100 +#define F2FS_FEATURE_LOST_FOUND 0x0200#define F2FS_HAS_FEATURE (sb, mask) \ ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
@@ -3186,6 +3187,7 @@ F2FS_FEATURE_FUNCS(inode_chksum, INODE_CHKSUM);F2FS_FEATURE_FUNCS (flexible_inline_xattr,FLEXIBLE_INLINE_XATTR );F2FS_FEATURE_FUNCS (quota_ino,QUOTA_INO );F2FS_FEATURE_FUNCS (inode_crtime,INODE_CRTIME ); +F2FS_FEATURE_FUNCS (lost_found,LOST_FOUND );#ifdef CONFIG_BLK_DEV_ZONED static inline int get_blkz_type(struct f2fs_sb_info *sbi,
fs/f2fs/super.c +12 -0
@@ -1797,6 +1797,18 @@ static int f2fs_get_context(struct inode *inode, void *ctx, size_t len)static int f2fs_set_context (struct inode *inode,const void *ctx,size_t len,void *fs_data) { +struct f2fs_sb_info *sbi =F2FS_I_SB (inode); + +/* +* Encrypting the root directory is not allowed because f2fsck +* expects lost+found directory to exist and remain unencrypted +* if LOST_FOUND feature is enabled. +* +*/ +if (f2fs_sb_has_lost_found (sbi->sb) && + inode->i_ino ==F2FS_ROOT_INO (sbi)) +return -EPERM ; +return f2fs_setxattr (inode,F2FS_XATTR_INDEX_ENCRYPTION ,F2FS_XATTR_NAME_ENCRYPTION_CONTEXT , ctx, len, fs_data,XATTR_CREATE );
Signature · 6 lines
2.11.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Chao Yu
maintainerQuoted 1 line · Sheng Yong
Introduce lost+found feature. The lost+found is a directory which saves
Nitpick, lost_found feature...
Needs to add /sys/fs/f2fs/features/lost_found sysfs entry, and show 'lost_found' in /sys/fs/f2fs/<dev>/features.
Thanks,
Quoted 48 lines
unreachable files. If f2fsck finds a file which has no parent, or the parent is removed by f2fsck, the file will be placed in lost+found directory.
According fscrypt policy, lost+found could not be encrypted. As a result, the root directory cannot be encrypted. So if lost+found feature is enabled, let's avoid to encrypt root directory.
Signed-off-by Sheng Yong <[email protected]>--- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/super.c | 12 ++++++++++++ 2 files changed, 14 insertions(+)fs/f2fs/f2fs.h +2
-0@@ -125,6 +125,7 @@ struct f2fs_mount_info {#define F2FS_FEATURE_FLEXIBLE_INLINE_XATTR 0x0040#define F2FS_FEATURE_QUOTA_INO 0x0080#define F2FS_FEATURE_INODE_CRTIME 0x0100 +#define F2FS_FEATURE_LOST_FOUND 0x0200#define F2FS_HAS_FEATURE (sb, mask) \ ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)@@ -3186,6 +3187,7 @@ F2FS_FEATURE_FUNCS(inode_chksum, INODE_CHKSUM);F2FS_FEATURE_FUNCS (flexible_inline_xattr,FLEXIBLE_INLINE_XATTR );F2FS_FEATURE_FUNCS (quota_ino,QUOTA_INO );F2FS_FEATURE_FUNCS (inode_crtime,INODE_CRTIME ); +F2FS_FEATURE_FUNCS (lost_found,LOST_FOUND );#ifdef CONFIG_BLK_DEV_ZONED static inline int get_blkz_type(struct f2fs_sb_info *sbi,fs/f2fs/super.c +5
-0@@ -1797,6 +1797,18 @@ static int f2fs_get_context(struct inode *inode, void *ctx, size_t len)static int f2fs_set_context (struct inode *inode,const void *ctx,size_t len,void *fs_data) { +struct f2fs_sb_info *sbi =F2FS_I_SB (inode); + +/* +* Encrypting the root directory is not allowed because f2fsck +* expects lost+found directory to exist and remain unencrypted
fs/f2fs/super.c static int f2fs_get_context(struct inode *inode, void *ctx, size_t len) · line 1814
Quoted 10 lines
fs/f2fs/super.c +7
-0+* if LOST_FOUND feature is enabled. +* +*/ +if (f2fs_sb_has_lost_found (sbi->sb) && + inode->i_ino ==F2FS_ROOT_INO (sbi)) +return -EPERM ; +return f2fs_setxattr (inode,F2FS_XATTR_INDEX_ENCRYPTION ,F2FS_XATTR_NAME_ENCRYPTION_CONTEXT , ctx, len, fs_data,XATTR_CREATE );
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Hi, Chao
Quoted 7 lines · Chao Yu
Quoted 1 line · Sheng Yong
Introduce lost+found feature. The lost+found is a directory which saves
Nitpick,
lost_foundfeature...Needs to add
/sys/fs/f2fs/features/lost_foundsysfs entry, and show 'lost_found' in /sys/fs/f2fs/<dev>/features.
I will add this sysfs entry in the next version :)
Thanks,
Sheng
Quoted 55 lines
Thanks,
Quoted 52 lines
unreachable files. If f2fsck finds a file which has no parent, or the parent is removed by f2fsck, the file will be placed in lost+found directory.
According fscrypt policy, lost+found could not be encrypted. As a result, the root directory cannot be encrypted. So if lost+found feature is enabled, let's avoid to encrypt root directory.
Signed-off-by Sheng Yong <[email protected]>--- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/super.c | 12 ++++++++++++ 2 files changed, 14 insertions(+)fs/f2fs/f2fs.h +2
-0@@ -125,6 +125,7 @@ struct f2fs_mount_info {#define F2FS_FEATURE_FLEXIBLE_INLINE_XATTR 0x0040#define F2FS_FEATURE_QUOTA_INO 0x0080#define F2FS_FEATURE_INODE_CRTIME 0x0100 +#define F2FS_FEATURE_LOST_FOUND 0x0200#define F2FS_HAS_FEATURE (sb, mask) \ ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)@@ -3186,6 +3187,7 @@ F2FS_FEATURE_FUNCS(inode_chksum, INODE_CHKSUM);F2FS_FEATURE_FUNCS (flexible_inline_xattr,FLEXIBLE_INLINE_XATTR );F2FS_FEATURE_FUNCS (quota_ino,QUOTA_INO );F2FS_FEATURE_FUNCS (inode_crtime,INODE_CRTIME ); +F2FS_FEATURE_FUNCS (lost_found,LOST_FOUND );#ifdef CONFIG_BLK_DEV_ZONED static inline int get_blkz_type(struct f2fs_sb_info *sbi,fs/f2fs/super.c +10
-0@@ -1797,6 +1797,18 @@ static int f2fs_get_context(struct inode *inode, void *ctx, size_t len)static int f2fs_set_context (struct inode *inode,const void *ctx,size_t len,void *fs_data) { +struct f2fs_sb_info *sbi =F2FS_I_SB (inode); + +/* +* Encrypting the root directory is not allowed because f2fsck +* expects lost+found directory to exist and remain unencrypted +* if LOST_FOUND feature is enabled. +* +*/ +if (f2fs_sb_has_lost_found (sbi->sb) && + inode->i_ino ==F2FS_ROOT_INO (sbi))
Quoted 9 lines
fs/f2fs/super.c static int f2fs_get_context(struct inode *inode, void *ctx, size_t len) · line 1814
Quoted 6 lines
fs/f2fs/super.c +2
-0+return -EPERM ; +return f2fs_setxattr (inode,F2FS_XATTR_INDEX_ENCRYPTION ,F2FS_XATTR_NAME_ENCRYPTION_CONTEXT , ctx, len, fs_data,XATTR_CREATE );.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Jaegeuk Kim
maintainerQuoted 2 lines · Sheng Yong
This patchset introduces lost+found feature in f2fs. If the feature is enabled, f2fs should avoid to encrypting root directory.
In that case, we need to add test_dummy_encryption likewise ext4.
Quoted 11 lines
For more information, please check the mail "f2fs-tools: introduce lost+ found feature".
Thanks,
ShengSheng Yong (2):
f2fs: clean upf2fs_sb_has_xxxfunctions
f2fs: introduce lost+found feature
Quoted 10 lines
fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 53 +++++++++++++++-------------------------------------- fs/f2fs/file.c | 6 +++--- fs/f2fs/segment.c | 4 ++-- fs/f2fs/super.c | 26 +++++++++++++++++++------- fs/f2fs/sysfs.c | 4 ++-- 6 files changed, 42 insertions(+), 53 deletions(-)Signature · 1 line
2.11.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Hi, Jaegeuk
Quoted 6 lines · Jaegeuk Kim
Quoted 2 lines · Sheng Yong
This patchset introduces lost+found feature in f2fs. If the feature is enabled, f2fs should avoid to encrypting root directory.
In that case, we need to add
test_dummy_encryptionlikewise ext4.
If the test_dummy_encryption is only used for some a testcase, I think it's ok not to add it. The lost_found feature is not enabled by default, so if we don't specify "-O lost_found" for mkfs, root directory is allowed to be encrypted. If I miss something, please let me know :)
thanks,
Sheng
Quoted 19 lines
Quoted 19 lines
For more information, please check the mail "f2fs-tools: introduce lost+ found feature".
Thanks,
ShengSheng Yong (2):
f2fs: clean upf2fs_sb_has_xxxfunctions
f2fs: introduce lost+found featurefs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 53 +++++++++++++++-------------------------------------- fs/f2fs/file.c | 6 +++--- fs/f2fs/segment.c | 4 ++-- fs/f2fs/super.c | 26 +++++++++++++++++++------- fs/f2fs/sysfs.c | 4 ++-- 6 files changed, 42 insertions(+), 53 deletions(-)
Quoted 5 lines
Quoted 2 lines
Signature · 1 line
2.11.0.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Jaegeuk Kim
maintainerQuoted 7 lines · Sheng Yong
Hi, Jaegeuk
Quoted 4 lines · Jaegeuk Kim
Quoted 2 lines · Sheng Yong
This patchset introduces lost+found feature in f2fs. If the feature is enabled, f2fs should avoid to encrypting root directory.
Quoted 6 lines
Quoted 2 lines
In that case, we need to add
test_dummy_encryptionlikewise ext4.If the
test_dummy_encryptionis only used for some a testcase, I think it's ok not to add it. Thelost_foundfeature is not enabled by default, so if we don't specify "-Olost_found" for mkfs, root directory is allowed to be encrypted. If I miss something, please let me know :)
No, we have to be able to test lost_found with encryption. :)
Thanks,
Quoted 28 lines
thanks,
ShengQuoted 24 lines
Quoted 11 lines
For more information, please check the mail "f2fs-tools: introduce lost+ found feature".
Thanks,
ShengSheng Yong (2):
f2fs: clean upf2fs_sb_has_xxxfunctions
f2fs: introduce lost+found featureQuoted 10 lines
fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 53 +++++++++++++++-------------------------------------- fs/f2fs/file.c | 6 +++--- fs/f2fs/segment.c | 4 ++-- fs/f2fs/super.c | 26 +++++++++++++++++++------- fs/f2fs/sysfs.c | 4 ++-- 6 files changed, 42 insertions(+), 53 deletions(-)Signature · 1 line
2.11.0.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot