[f2fs-dev] [PATCH] f2fs: remove unneed reada during build free nids

2018-02-08 Thread Yunlei He
This patch remove unneed reada during build free nids.
If few nids left, three will introduce a lot of no hit
read io.

Signed-off-by: Yunlei He 
---
 fs/f2fs/node.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 833b46b..ad28965 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2033,10 +2033,6 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, 
bool sync, bool mount)
return;
}
 
-   /* readahead nat pages to be scanned */
-   ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES,
-   META_NAT, true);
-
down_read(_i->nat_tree_lock);
 
while (1) {
@@ -2052,7 +2048,12 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, 
bool sync, bool mount)
if (unlikely(nid >= nm_i->max_nid))
nid = 0;
 
-   if (++i >= FREE_NID_PAGES)
+   /* bg build, no more than 8 pages */
+   if ((!sync || mount) && ++i >= FREE_NID_PAGES)
+   break;
+
+   /* fg build, until free nids is not zero */
+   if (sync && !mount && nm_i->nid_cnt[FREE_NID])
break;
}
 
@@ -2063,9 +2064,6 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, 
bool sync, bool mount)
scan_curseg_cache(sbi);
 
up_read(_i->nat_tree_lock);
-
-   ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nm_i->next_scan_nid),
-   nm_i->ra_nid_pages, META_NAT, false);
 }
 
 void build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
-- 
1.9.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [RFC PATCH 2/2] f2fs: introduce lost+found feature

2018-02-08 Thread Sheng Yong

Hi, Chao

On 2018/2/8 21:29, Chao Yu wrote:

On 2018/2/6 12:31, Sheng Yong wrote:

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//features.


I will add this sysfs entry in the next version :)

Thanks,
Sheng


Thanks,


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 
---
  fs/f2fs/f2fs.h  |  2 ++
  fs/f2fs/super.c | 12 
  2 files changed, 14 insertions(+)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a60d56a96f9b..d9c9be6ea5d5 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -125,6 +125,7 @@ struct f2fs_mount_info {
  #define F2FS_FEATURE_FLEXIBLE_INLINE_XATTR0x0040
  #define F2FS_FEATURE_QUOTA_INO0x0080
  #define F2FS_FEATURE_INODE_CRTIME 0x0100
+#define F2FS_FEATURE_LOST_FOUND0x0200
  
  #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,
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index b39ab55ab1b5..5f536e878d21 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -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);



.




--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [RFC PATCH 4/5] mkfs.f2fs: create lost+found directory

2018-02-08 Thread Sheng Yong

Hi, Chao

On 2018/2/8 23:08, Chao Yu wrote:

On 2018/2/6 12:31, Sheng Yong wrote:

This patch introduces a new feature F2FS_FEATURE_LOST_FOUND. It can be
switched on by indicating a new option `lost+found' with -O. If


Not sure, do we need to change this option to 'lost_found' to follow other
generic -O options?


I'm also not sure about this, since there is already a `lost_found' in fsck :(




F2FS_FEATUER_LOST_FOUND is enabled, an empty directory lost+found is
created during mkfs.

This is a preparation for fsck. During fsck, the directory is used to
save unreachable files, which have no parent directory or their parent
directory is removed by fsck. Encrypted files are also allowed to be
saved here.


[...]

+static int f2fs_write_lpf_inode(void)
+{
+   struct f2fs_node *raw_node;
+   u_int64_t blk_size_bytes, data_blk_nor;
+   u_int64_t main_area_node_seg_blk_offset;
+   int err = 0;
+
+   ASSERT(c.lpf_ino);
+
+   raw_node = calloc(F2FS_BLKSIZE, 1);
+   if (raw_node == NULL) {
+   MSG(1, "\tError: Calloc Failed for raw_node!!!\n");
+   return -1;
+   }
+
+   raw_node->footer.nid = cpu_to_le32(c.lpf_ino);
+   raw_node->footer.ino = raw_node->footer.nid;
+   raw_node->footer.cp_ver = cpu_to_le64(1);
+   raw_node->footer.next_blkaddr = cpu_to_le32(
+   get_sb(main_blkaddr) +
+   c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg +
+   1 + c.quota_inum + 1);
+
+   raw_node->i.i_mode = cpu_to_le16(0x41c0); /* 0700 */
+   raw_node->i.i_links = cpu_to_le32(2);
+   raw_node->i.i_uid = cpu_to_le32(getuid());
+   raw_node->i.i_gid = cpu_to_le32(getgid());
+
+   blk_size_bytes = 1 << get_sb(log_blocksize);
+   raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes); /* dentry */
+   raw_node->i.i_blocks = cpu_to_le64(2);
+
+   raw_node->i.i_atime = cpu_to_le32(time(NULL));
+   raw_node->i.i_atime_nsec = 0;
+   raw_node->i.i_ctime = cpu_to_le32(time(NULL));
+   raw_node->i.i_ctime_nsec = 0;
+   raw_node->i.i_mtime = cpu_to_le32(time(NULL));
+   raw_node->i.i_mtime_nsec = 0;
+   raw_node->i.i_generation = 0;
+   raw_node->i.i_xattr_nid = 0;
+   raw_node->i.i_flags = 0;
+   raw_node->i.i_pino = le32_to_cpu(sb->root_ino);
+   raw_node->i.i_namelen = le32_to_cpu(strlen(LPF));
+   memcpy(raw_node->i.i_name, LPF, strlen(LPF));
+   raw_node->i.i_current_depth = cpu_to_le32(1);
+   raw_node->i.i_dir_level = DEF_DIR_LEVEL;
+
+   if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
+   raw_node->i.i_inline = F2FS_EXTRA_ATTR;
+   raw_node->i.i_extra_isize =
+   cpu_to_le16(F2FS_TOTAL_EXTRA_ATTR_SIZE);
+   }
+
+   if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA))
+   raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID);


Need to handle inode_crtime case?


Right, thanks.



+
+   data_blk_nor = f2fs_add_default_dentry_lpf();
+   if (data_blk_nor < 0) {
+   MSG(1, "\tError: Failed to add default dentries for 
lost+found!!!\n");
+   err = -1;
+   goto exit;
+   }
+   raw_node->i.i_addr[get_extra_isize(raw_node)] = 
cpu_to_le32(data_blk_nor);
+
+   if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM))
+   raw_node->i.i_inode_checksum =
+   cpu_to_le32(f2fs_inode_chksum(raw_node));
+
+   main_area_node_seg_blk_offset = get_sb(main_blkaddr);
+   main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE] *
+   c.blks_per_seg + c.quota_inum + 1;
+
+   DBG(1, "\tWriting lost+found inode (hot node), %x %x %x at offset 
0x%08"PRIu64"\n",
+   get_sb(main_blkaddr),
+   c.cur_seg[CURSEG_HOT_NODE],
+   c.blks_per_seg, main_area_node_seg_blk_offset);
+   if (dev_write_block(raw_node, main_area_node_seg_blk_offset)) {
+   MSG(1, "\tError: While writing the raw_node to disk!!!\n");
+   err = -1;
+   goto exit;
+   }
+
+   c.lpf_inum++;
+exit:
+   free(raw_node);
+   return err;
+}
+
  static int f2fs_add_default_dentry_root(void)
  {
struct f2fs_dentry_block *dent_blk = NULL;
@@ -1326,6 +1495,27 @@ static int f2fs_add_default_dentry_root(void)
test_and_set_bit_le(0, dent_blk->dentry_bitmap);
test_and_set_bit_le(1, dent_blk->dentry_bitmap);
  
+	if (c.lpf_ino) {

+   int len = strlen(LPF);
+   f2fs_hash_t hash = f2fs_dentry_hash((unsigned char *)LPF, len);
+
+   dent_blk->dentry[2].hash_code = cpu_to_le32(hash);
+   dent_blk->dentry[2].ino = cpu_to_le32(c.lpf_ino);
+   dent_blk->dentry[2].name_len = strlen(LPF);


cpu_to_le16(strlen(LPF))


Will re-check all endianness problems :)



+   dent_blk->dentry[2].file_type = F2FS_FT_DIR;
+  

Re: [f2fs-dev] [RFC PATCH 1/5] mkfs.f2fs: introduce mkfs parameters in f2fs_configuration

2018-02-08 Thread Sheng Yong

Hi, Chao

Add Hyojun.

On 2018/2/8 21:30, Chao Yu wrote:

On 2018/2/6 12:31, Sheng Yong wrote:

/* only root inode was written before truncating dnodes */
last_inode_pos = start_inode_pos +
-   c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg + quota_inum;
+   c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg + c.quota_inum;


- f2fs_create_root_dir
  - f2fs_write_root_inode
   - discard_obsolete_dnode
 access c.quota_inum
  - f2fs_write_qf_inode
update c.quota_inum

Should c.quota_inum be initialized more early?


I think we should only count quota inodes if thye are already initialized.
Otherwise, if quota_ino is not enabled, there is only one inode (root) in
CURSEG_HOT_NODE, and two blocks next to root inode will not be discarded.

I'm a bit confused about the `offset' scale in discard_obsolete_dnode.
It seems `if (offset >= start_inode_pos || offset <= last_inode_pos)'
will always be true?

Hi, Hyojun, could you please also have a look at this, thanks :)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 0fc8b30..6c9ae22 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -963,7 +963,7 @@ static int discard_obsolete_dnode(struct f2fs_node 
*raw_node, u_int64_t offset)
}
offset = next_blkaddr;
/* should avoid recursive chain due to stale data */
-   if (offset >= start_inode_pos || offset <= last_inode_pos)
+   if (offset <= last_inode_pos)
break;
} while (1);

thanks,
Sheng


Thanks,

.




--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] mkfs.f2fs: fix to handle endianness in f2fs_write_check_point_pack

2018-02-08 Thread Chao Yu
From: Chao Yu 

This patch fixes to handle missing endianness in f2fs_write_check_point_pack.

Signed-off-by: Chao Yu 
---
 mkfs/f2fs_format.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 93e9fea..4c3df96 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -783,7 +783,7 @@ static int f2fs_write_check_point_pack(void)
 
for (j = 0; j < QUOTA_DATA(qtype); j++) {
(sum_entry + off + j)->nid = sb->qf_ino[qtype];
-   (sum_entry + off + j)->ofs_in_node = j;
+   (sum_entry + off + j)->ofs_in_node = cpu_to_le16(j);
}
off += QUOTA_DATA(qtype);
}
-- 
2.14.1.145.gb3622a4ee


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [RFC PATCH 4/5] mkfs.f2fs: create lost+found directory

2018-02-08 Thread Chao Yu
On 2018/2/6 12:31, Sheng Yong wrote:
> This patch introduces a new feature F2FS_FEATURE_LOST_FOUND. It can be
> switched on by indicating a new option `lost+found' with -O. If

Not sure, do we need to change this option to 'lost_found' to follow other
generic -O options?

> F2FS_FEATUER_LOST_FOUND is enabled, an empty directory lost+found is
> created during mkfs.
> 
> This is a preparation for fsck. During fsck, the directory is used to
> save unreachable files, which have no parent directory or their parent
> directory is removed by fsck. Encrypted files are also allowed to be
> saved here.
> 
> Signed-off-by: Sheng Yong 
> ---
>  fsck/mount.c|   3 +
>  include/f2fs_fs.h   |   6 ++
>  mkfs/f2fs_format.c  | 223 
> +---
>  mkfs/f2fs_format_main.c |   2 +
>  4 files changed, 222 insertions(+), 12 deletions(-)
> 
> diff --git a/fsck/mount.c b/fsck/mount.c
> index 46cb571..df53c48 100644
> --- a/fsck/mount.c
> +++ b/fsck/mount.c
> @@ -460,6 +460,9 @@ void print_sb_state(struct f2fs_super_block *sb)
>   if (f & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) {
>   MSG(0, "%s", " inode_crtime");
>   }
> + if (f & cpu_to_le32(F2FS_FEATURE_LOST_FOUND)) {
> + MSG(0, "%s", " lost+found");
> + }
>   MSG(0, "\n");
>   MSG(0, "Info: superblock encrypt level = %d, salt = ",
>   sb->encryption_level);
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> index ca4522d..093c402 100644
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -291,6 +291,8 @@ static inline uint64_t bswap_64(uint64_t val)
>  
>  #define VERSION_LEN  256
>  
> +#define LPF "lost+found"
> +
>  enum f2fs_config_func {
>   MKFS,
>   FSCK,
> @@ -369,6 +371,9 @@ struct f2fs_configuration {
>   u_int32_t next_free_nid;
>   u_int32_t quota_inum;
>   u_int32_t quota_dnum;
> + u_int32_t lpf_inum;
> + u_int32_t lpf_dnum;
> + u_int32_t lpf_ino;
>  
>   /* defragmentation parameters */
>   int defrag_shrink;
> @@ -557,6 +562,7 @@ enum {
>  #define F2FS_FEATURE_FLEXIBLE_INLINE_XATTR   0x0040
>  #define F2FS_FEATURE_QUOTA_INO   0x0080
>  #define F2FS_FEATURE_INODE_CRTIME0x0100
> +#define F2FS_FEATURE_LOST_FOUND  0x0200
>  
>  #define MAX_VOLUME_NAME  512
>  
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index bda3c9d..33dd98c 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -426,6 +426,9 @@ static int f2fs_prepare_super_block(void)
>   qtype, c.next_free_nid - 1);
>   }
>  
> + if (c.feature & cpu_to_le32(F2FS_FEATURE_LOST_FOUND))
> + c.lpf_ino = c.next_free_nid++;
> +
>   if (total_zones <= 6) {
>   MSG(1, "\tError: %d zones: Need more zones "
>   "by shrinking zone size\n", total_zones);
> @@ -608,9 +611,10 @@ static int f2fs_write_check_point_pack(void)
>   set_cp(cur_data_segno[i], 0x);
>   }
>  
> - set_cp(cur_node_blkoff[0], 1 + c.quota_inum);
> - set_cp(cur_data_blkoff[0], 1 + c.quota_dnum);
> - set_cp(valid_block_count, 2 + c.quota_inum + c.quota_dnum);
> + set_cp(cur_node_blkoff[0], 1 + c.quota_inum + c.lpf_inum);
> + set_cp(cur_data_blkoff[0], 1 + c.quota_dnum + c.lpf_dnum);
> + set_cp(valid_block_count, 2 + c.quota_inum + c.quota_dnum +
> + c.lpf_inum + c.lpf_dnum);
>   set_cp(rsvd_segment_count, c.reserved_segments);
>   set_cp(overprov_segment_count, (get_sb(segment_count_main) -
>   get_cp(rsvd_segment_count)) *
> @@ -642,8 +646,8 @@ static int f2fs_write_check_point_pack(void)
>  
>   set_cp(ckpt_flags, flags);
>   set_cp(cp_pack_start_sum, 1 + get_sb(cp_payload));
> - set_cp(valid_node_count, 1 + c.quota_inum);
> - set_cp(valid_inode_count, 1 + c.quota_inum);
> + set_cp(valid_node_count, 1 + c.quota_inum + c.lpf_inum);
> + set_cp(valid_inode_count, 1 + c.quota_inum + c.lpf_inum);
>   set_cp(next_free_nid, c.next_free_nid);
>   set_cp(sit_ver_bitmap_bytesize, ((get_sb(segment_count_sit) / 2) <<
>   get_sb(log_blocks_per_seg)) / 8);
> @@ -702,7 +706,7 @@ static int f2fs_write_check_point_pack(void)
>   SET_SUM_TYPE((>footer), SUM_TYPE_DATA);
>  
>   journal = >journal;
> - journal->n_nats = cpu_to_le16(1 + c.quota_inum);
> + journal->n_nats = cpu_to_le16(1 + c.quota_inum + c.lpf_inum);
>   journal->nat_j.entries[0].nid = sb->root_ino;
>   journal->nat_j.entries[0].ne.version = 0;
>   journal->nat_j.entries[0].ne.ino = sb->root_ino;
> @@ -723,6 +727,16 @@ static int f2fs_write_check_point_pack(void)
>   i++;
>   }
>  
> + if (c.lpf_inum) {
> + journal->nat_j.entries[i].nid = cpu_to_le32(c.lpf_ino);
> + journal->nat_j.entries[i].ne.version = 0;
> + 

Re: [f2fs-dev] [RFC PATCH 3/5] fsck.f2fs: integrate sanity_check_inode to __check_inode_mode

2018-02-08 Thread Chao Yu
On 2018/2/6 12:31, Sheng Yong wrote:
> In sanity_check_nid, __check_inode_mode will check i_mode value of an
> inode. So integrate sanity_check_inode to __check_inode_mode to clean
> up the code.
> 
> Signed-off-by: Sheng Yong 
> ---
>  fsck/fsck.c | 26 +-
>  1 file changed, 5 insertions(+), 21 deletions(-)
> 
> diff --git a/fsck/fsck.c b/fsck/fsck.c
> index 29823a1..fcaab14 100644
> --- a/fsck/fsck.c
> +++ b/fsck/fsck.c
> @@ -334,6 +334,11 @@ static int __check_inode_mode(u32 nid, enum FILE_TYPE 
> ftype, u32 mode)
>  {
>   if (ftype >= F2FS_FT_MAX)
>   return 0;
> + /* f2fs_iget will return -EIO if mode is not valid file type */
> + if (!S_ISLNK(mode) && !S_ISREG(mode) && !S_ISDIR(mode) &&
> + !S_ISCHR(mode) && !S_ISBLK(mode) && !S_ISFIFO(mode) &&
> + !S_ISSOCK(mode))

Need an extra error message for this case instead of below one.

Thanks,

> + goto err;
>   if (S_ISLNK(mode) && ftype != F2FS_FT_SYMLINK)
>   goto err;
>   if (S_ISREG(mode) && ftype != F2FS_FT_REG_FILE)
> @@ -465,25 +470,6 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, 
> u32 nid,
>   return 0;
>  }
>  
> -static int sanity_check_inode(struct f2fs_sb_info *sbi, struct f2fs_node 
> *node)
> -{
> - struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
> - struct f2fs_inode *fi = >i;
> -
> - if (!(le16_to_cpu(fi->i_mode) & S_IFMT)) {
> - ASSERT_MSG("i_mode is not valid. [0x%x]", 
> le16_to_cpu(fi->i_mode));
> - goto remove_node;
> - }
> -
> - return 0;
> -
> -remove_node:
> - f2fs_set_bit(le32_to_cpu(node->footer.ino), fsck->nat_area_bitmap);
> - fsck->chk.valid_blk_cnt--;
> - fsck->chk.valid_node_cnt--;
> - return -EINVAL;
> -}
> -
>  static int fsck_chk_xattr_blk(struct f2fs_sb_info *sbi, u32 ino,
>   u32 x_nid, u32 *blk_cnt)
>  {
> @@ -528,8 +514,6 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi, struct 
> f2fs_inode *inode,
>   if (ntype == TYPE_INODE) {
>   struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
>  
> - if (sanity_check_inode(sbi, node_blk))
> - goto err;
>   fsck_chk_inode_blk(sbi, nid, ftype, node_blk, blk_cnt, , 
> child);
>   quota_add_inode_usage(fsck->qctx, nid, _blk->i);
>   } else {
> 

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [RFC PATCH 2/5] f2fs-tools: init f2fs_configuration as 0

2018-02-08 Thread Chao Yu
On 2018/2/6 12:31, Sheng Yong wrote:
> Signed-off-by: Sheng Yong 

Reviewed-by: Chao Yu 

Thanks,

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [RFC PATCH 1/5] mkfs.f2fs: introduce mkfs parameters in f2fs_configuration

2018-02-08 Thread Chao Yu
On 2018/2/6 12:31, Sheng Yong wrote:
>   /* only root inode was written before truncating dnodes */
>   last_inode_pos = start_inode_pos +
> - c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg + quota_inum;
> + c.cur_seg[CURSEG_HOT_NODE] * c.blks_per_seg + c.quota_inum;

- f2fs_create_root_dir
 - f2fs_write_root_inode
  - discard_obsolete_dnode
access c.quota_inum
 - f2fs_write_qf_inode
   update c.quota_inum

Should c.quota_inum be initialized more early?

Thanks,

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [RFC PATCH 2/2] f2fs: introduce lost+found feature

2018-02-08 Thread Chao Yu
On 2018/2/6 12:31, Sheng Yong wrote:
> 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//features.

Thanks,

> 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 
> ---
>  fs/f2fs/f2fs.h  |  2 ++
>  fs/f2fs/super.c | 12 
>  2 files changed, 14 insertions(+)
> 
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index a60d56a96f9b..d9c9be6ea5d5 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -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_CRTIME0x0100
> +#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,
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index b39ab55ab1b5..5f536e878d21 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -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);
> 

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [RFC PATCH 1/2] f2fs: clean up f2fs_sb_has_xxx functions

2018-02-08 Thread Chao Yu
On 2018/2/6 12:31, Sheng Yong wrote:
> This patch introduces F2FS_FEATURE_FUNCS to clean up the definitions of
> different f2fs_sb_has_xxx functions.
> 
> Signed-off-by: Sheng Yong 

Reviewed-by: Chao Yu 

Thanks,

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: set_code_data in move_data_block

2018-02-08 Thread Yunlong Song
Signed-off-by: Yunlong Song 
---
 fs/f2fs/gc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index b9d93fd..2095630 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -692,6 +692,7 @@ static void move_data_block(struct inode *inode, block_t 
bidx,
fio.op = REQ_OP_WRITE;
fio.op_flags = REQ_SYNC;
fio.new_blkaddr = newaddr;
+   set_cold_data(fio.page);
err = f2fs_submit_page_write();
if (err) {
if (PageWriteback(fio.encrypted_page))
-- 
1.8.5.2


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel