Re: [PATCH] nilfs2: Fix typos in comments
Hi Andrew, Please also queue this typo fix patch that came separately. Thanks, Ryusuke Konishi On Fri, Apr 9, 2021 at 1:35 PM Ryusuke Konishi wrote: > > From: Lu Jialin > > numer -> number in fs/nilfs2/cpfile.c > Decription -> Description in fs/nilfs2/ioctl.c > isntance -> instance in fs/nilfs2/the_nilfs.c > > Signed-off-by: Lu Jialin > Link: https://lore.kernel.org/r/20210409022519.176988-1-lujial...@huawei.com > Signed-off-by: Ryusuke Konishi > --- > fs/nilfs2/cpfile.c| 2 +- > fs/nilfs2/ioctl.c | 4 ++-- > fs/nilfs2/the_nilfs.c | 2 +- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c > index 025fb082575a..ce144776b4ef 100644 > --- a/fs/nilfs2/cpfile.c > +++ b/fs/nilfs2/cpfile.c > @@ -293,7 +293,7 @@ void nilfs_cpfile_put_checkpoint(struct inode *cpfile, > __u64 cno, > * nilfs_cpfile_delete_checkpoints - delete checkpoints > * @cpfile: inode of checkpoint file > * @start: start checkpoint number > - * @end: end checkpoint numer > + * @end: end checkpoint number > * > * Description: nilfs_cpfile_delete_checkpoints() deletes the checkpoints in > * the period from @start to @end, excluding @end itself. The checkpoints > diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c > index b053b40315bf..d1db73030085 100644 > --- a/fs/nilfs2/ioctl.c > +++ b/fs/nilfs2/ioctl.c > @@ -1058,7 +1058,7 @@ static int nilfs_ioctl_resize(struct inode *inode, > struct file *filp, > * @inode: inode object > * @argp: pointer on argument from userspace > * > - * Decription: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It > + * Description: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It > * checks the arguments from userspace and calls nilfs_sufile_trim_fs, which > * performs the actual trim operation. > * > @@ -1100,7 +1100,7 @@ static int nilfs_ioctl_trim_fs(struct inode *inode, > void __user *argp) > * @inode: inode object > * @argp: pointer on argument from userspace > * > - * Decription: nilfs_ioctl_set_alloc_range() function defines lower limit > + * Description: nilfs_ioctl_set_alloc_range() function defines lower limit > * of segments in bytes and upper limit of segments in bytes. > * The NILFS_IOCTL_SET_ALLOC_RANGE is used by nilfs_resize utility. > * > diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c > index 221a1cc597f0..8b7b01a380ce 100644 > --- a/fs/nilfs2/the_nilfs.c > +++ b/fs/nilfs2/the_nilfs.c > @@ -195,7 +195,7 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs, > /** > * load_nilfs - load and recover the nilfs > * @nilfs: the_nilfs structure to be released > - * @sb: super block isntance used to recover past segment > + * @sb: super block instance used to recover past segment > * > * load_nilfs() searches and load the latest super root, > * attaches the last segment, and does recovery if needed. > -- > 1.8.3.1 >
[PATCH] nilfs2: Fix typos in comments
From: Lu Jialin numer -> number in fs/nilfs2/cpfile.c Decription -> Description in fs/nilfs2/ioctl.c isntance -> instance in fs/nilfs2/the_nilfs.c Signed-off-by: Lu Jialin Link: https://lore.kernel.org/r/20210409022519.176988-1-lujial...@huawei.com Signed-off-by: Ryusuke Konishi --- fs/nilfs2/cpfile.c| 2 +- fs/nilfs2/ioctl.c | 4 ++-- fs/nilfs2/the_nilfs.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c index 025fb082575a..ce144776b4ef 100644 --- a/fs/nilfs2/cpfile.c +++ b/fs/nilfs2/cpfile.c @@ -293,7 +293,7 @@ void nilfs_cpfile_put_checkpoint(struct inode *cpfile, __u64 cno, * nilfs_cpfile_delete_checkpoints - delete checkpoints * @cpfile: inode of checkpoint file * @start: start checkpoint number - * @end: end checkpoint numer + * @end: end checkpoint number * * Description: nilfs_cpfile_delete_checkpoints() deletes the checkpoints in * the period from @start to @end, excluding @end itself. The checkpoints diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index b053b40315bf..d1db73030085 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c @@ -1058,7 +1058,7 @@ static int nilfs_ioctl_resize(struct inode *inode, struct file *filp, * @inode: inode object * @argp: pointer on argument from userspace * - * Decription: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It + * Description: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It * checks the arguments from userspace and calls nilfs_sufile_trim_fs, which * performs the actual trim operation. * @@ -1100,7 +1100,7 @@ static int nilfs_ioctl_trim_fs(struct inode *inode, void __user *argp) * @inode: inode object * @argp: pointer on argument from userspace * - * Decription: nilfs_ioctl_set_alloc_range() function defines lower limit + * Description: nilfs_ioctl_set_alloc_range() function defines lower limit * of segments in bytes and upper limit of segments in bytes. * The NILFS_IOCTL_SET_ALLOC_RANGE is used by nilfs_resize utility. * diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 221a1cc597f0..8b7b01a380ce 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c @@ -195,7 +195,7 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs, /** * load_nilfs - load and recover the nilfs * @nilfs: the_nilfs structure to be released - * @sb: super block isntance used to recover past segment + * @sb: super block instance used to recover past segment * * load_nilfs() searches and load the latest super root, * attaches the last segment, and does recovery if needed. -- 1.8.3.1
Re: [PATCH v2 -next] nilfs2: Fix typos in comments
Thank you. Will apply this. Ryusuke Konishi On Fri, Apr 9, 2021 at 11:25 AM Lu Jialin wrote: > > numer -> number in fs/nilfs2/cpfile.c > Decription -> Description in fs/nilfs2/ioctl.c > isntance -> instance in fs/nilfs2/the_nilfs.c > > Signed-off-by: Lu Jialin > --- > v2: > Exclude two typo fixes of "retured -> returned", which has been fixed in > previous patch. > fs/nilfs2/cpfile.c| 2 +- > fs/nilfs2/ioctl.c | 4 ++-- > fs/nilfs2/the_nilfs.c | 2 +- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c > index 025fb082575a..ce144776b4ef 100644 > --- a/fs/nilfs2/cpfile.c > +++ b/fs/nilfs2/cpfile.c > @@ -293,7 +293,7 @@ void nilfs_cpfile_put_checkpoint(struct inode *cpfile, > __u64 cno, > * nilfs_cpfile_delete_checkpoints - delete checkpoints > * @cpfile: inode of checkpoint file > * @start: start checkpoint number > - * @end: end checkpoint numer > + * @end: end checkpoint number > * > * Description: nilfs_cpfile_delete_checkpoints() deletes the checkpoints in > * the period from @start to @end, excluding @end itself. The checkpoints > diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c > index b053b40315bf..d1db73030085 100644 > --- a/fs/nilfs2/ioctl.c > +++ b/fs/nilfs2/ioctl.c > @@ -1058,7 +1058,7 @@ static int nilfs_ioctl_resize(struct inode *inode, > struct file *filp, > * @inode: inode object > * @argp: pointer on argument from userspace > * > - * Decription: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It > + * Description: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It > * checks the arguments from userspace and calls nilfs_sufile_trim_fs, which > * performs the actual trim operation. > * > @@ -1100,7 +1100,7 @@ static int nilfs_ioctl_trim_fs(struct inode *inode, > void __user *argp) > * @inode: inode object > * @argp: pointer on argument from userspace > * > - * Decription: nilfs_ioctl_set_alloc_range() function defines lower limit > + * Description: nilfs_ioctl_set_alloc_range() function defines lower limit > * of segments in bytes and upper limit of segments in bytes. > * The NILFS_IOCTL_SET_ALLOC_RANGE is used by nilfs_resize utility. > * > diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c > index 221a1cc597f0..8b7b01a380ce 100644 > --- a/fs/nilfs2/the_nilfs.c > +++ b/fs/nilfs2/the_nilfs.c > @@ -195,7 +195,7 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs, > /** > * load_nilfs - load and recover the nilfs > * @nilfs: the_nilfs structure to be released > - * @sb: super block isntance used to recover past segment > + * @sb: super block instance used to recover past segment > * > * load_nilfs() searches and load the latest super root, > * attaches the last segment, and does recovery if needed. > -- > 2.17.1 >
Re: [PATCH -next] nilfs2: Fix typos in comments
Hi, This patch partially overlaps the following fix that I previously sent to Andrew: https://lkml.org/lkml/2021/4/8/114 Can you exclude two typo fixes of "retured -> returned" from yours ? Thanks, Ryusuke Konishi On Thu, Apr 8, 2021 at 11:08 PM Lu Jialin wrote: > > numer -> number in fs/nilfs2/cpfile.c and fs/nilfs2/segment.c > retured -> returned and Decription -> Description in fs/nilfs2/ioctl.c > isntance -> instance in fs/nilfs2/the_nilfs.c > No functionality changed. > > Signed-off-by: Lu Jialin > --- > fs/nilfs2/cpfile.c| 2 +- > fs/nilfs2/ioctl.c | 6 +++--- > fs/nilfs2/segment.c | 4 ++-- > fs/nilfs2/the_nilfs.c | 2 +- > 4 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c > index 025fb082575a..ce144776b4ef 100644 > --- a/fs/nilfs2/cpfile.c > +++ b/fs/nilfs2/cpfile.c > @@ -293,7 +293,7 @@ void nilfs_cpfile_put_checkpoint(struct inode *cpfile, > __u64 cno, > * nilfs_cpfile_delete_checkpoints - delete checkpoints > * @cpfile: inode of checkpoint file > * @start: start checkpoint number > - * @end: end checkpoint numer > + * @end: end checkpoint number > * > * Description: nilfs_cpfile_delete_checkpoints() deletes the checkpoints in > * the period from @start to @end, excluding @end itself. The checkpoints > diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c > index b053b40315bf..cbb59a6c4b81 100644 > --- a/fs/nilfs2/ioctl.c > +++ b/fs/nilfs2/ioctl.c > @@ -979,7 +979,7 @@ static int nilfs_ioctl_clean_segments(struct inode > *inode, struct file *filp, > * and metadata are written out to the device when it successfully > * returned. > * > - * Return Value: On success, 0 is retured. On errors, one of the following > + * Return Value: On success, 0 is returned. On errors, one of the following > * negative error code is returned. > * > * %-EROFS - Read only filesystem. > @@ -1058,7 +1058,7 @@ static int nilfs_ioctl_resize(struct inode *inode, > struct file *filp, > * @inode: inode object > * @argp: pointer on argument from userspace > * > - * Decription: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It > + * Description: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It > * checks the arguments from userspace and calls nilfs_sufile_trim_fs, which > * performs the actual trim operation. > * > @@ -1100,7 +1100,7 @@ static int nilfs_ioctl_trim_fs(struct inode *inode, > void __user *argp) > * @inode: inode object > * @argp: pointer on argument from userspace > * > - * Decription: nilfs_ioctl_set_alloc_range() function defines lower limit > + * Description: nilfs_ioctl_set_alloc_range() function defines lower limit > * of segments in bytes and upper limit of segments in bytes. > * The NILFS_IOCTL_SET_ALLOC_RANGE is used by nilfs_resize utility. > * > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index cd4da9535aed..686c8ee7b29c 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -2214,7 +2214,7 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info > *sci, int err) > * nilfs_construct_segment - construct a logical segment > * @sb: super block > * > - * Return Value: On success, 0 is retured. On errors, one of the following > + * Return Value: On success, 0 is returned. On errors, one of the following > * negative error code is returned. > * > * %-EROFS - Read only filesystem. > @@ -2251,7 +2251,7 @@ int nilfs_construct_segment(struct super_block *sb) > * @start: start byte offset > * @end: end byte offset (inclusive) > * > - * Return Value: On success, 0 is retured. On errors, one of the following > + * Return Value: On success, 0 is returned. On errors, one of the following > * negative error code is returned. > * > * %-EROFS - Read only filesystem. > diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c > index 221a1cc597f0..8b7b01a380ce 100644 > --- a/fs/nilfs2/the_nilfs.c > +++ b/fs/nilfs2/the_nilfs.c > @@ -195,7 +195,7 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs, > /** > * load_nilfs - load and recover the nilfs > * @nilfs: the_nilfs structure to be released > - * @sb: super block isntance used to recover past segment > + * @sb: super block instance used to recover past segment > * > * load_nilfs() searches and load the latest super root, > * attaches the last segment, and does recovery if needed. > -- > 2.17.1 >
Re: [PATCH] fs/nilfs2: fix misspellings using codespell tool
Hi Andrew, Please queue this typo fix for the next merge window. Thank you, Ryusuke Konishi On Thu, Apr 8, 2021 at 3:41 PM Ryusuke Konishi wrote: > > From: Liu xuzhi > > Two typos are found out by codespell tool \ > in 2217th and 2254th lines of segment.c: > > $ codespell ./fs/nilfs2/ > ./segment.c:2217 :retured ==> returned > ./segment.c:2254: retured ==> returned > > Fix two typos found by codespell. > > Signed-off-by: Liu xuzhi > Signed-off-by: Ryusuke Konishi > --- > fs/nilfs2/segment.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index cd4da9535aed..686c8ee7b29c 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -2214,7 +2214,7 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info > *sci, int err) > * nilfs_construct_segment - construct a logical segment > * @sb: super block > * > - * Return Value: On success, 0 is retured. On errors, one of the following > + * Return Value: On success, 0 is returned. On errors, one of the following > * negative error code is returned. > * > * %-EROFS - Read only filesystem. > @@ -2251,7 +2251,7 @@ int nilfs_construct_segment(struct super_block *sb) > * @start: start byte offset > * @end: end byte offset (inclusive) > * > - * Return Value: On success, 0 is retured. On errors, one of the following > + * Return Value: On success, 0 is returned. On errors, one of the following > * negative error code is returned. > * > * %-EROFS - Read only filesystem. > -- > 1.8.3.1 >
[PATCH] fs/nilfs2: fix misspellings using codespell tool
From: Liu xuzhi Two typos are found out by codespell tool \ in 2217th and 2254th lines of segment.c: $ codespell ./fs/nilfs2/ ./segment.c:2217 :retured ==> returned ./segment.c:2254: retured ==> returned Fix two typos found by codespell. Signed-off-by: Liu xuzhi Signed-off-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index cd4da9535aed..686c8ee7b29c 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -2214,7 +2214,7 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err) * nilfs_construct_segment - construct a logical segment * @sb: super block * - * Return Value: On success, 0 is retured. On errors, one of the following + * Return Value: On success, 0 is returned. On errors, one of the following * negative error code is returned. * * %-EROFS - Read only filesystem. @@ -2251,7 +2251,7 @@ int nilfs_construct_segment(struct super_block *sb) * @start: start byte offset * @end: end byte offset (inclusive) * - * Return Value: On success, 0 is retured. On errors, one of the following + * Return Value: On success, 0 is returned. On errors, one of the following * negative error code is returned. * * %-EROFS - Read only filesystem. -- 1.8.3.1
Re: KASAN: use-after-free in nilfs_mdt_destroy
Hi, I haven't yet succeeded to reproduce the issue with the attached program. How reproducible is it in your environment? (Does it take a long time to reproduce ?) Regards, Ryusuke Konishi On Mon, Mar 22, 2021 at 6:05 PM butt3rflyh4ck wrote: > > Hi, guy, I reported a bug found by syzkaller fuzzer with custom > modifications and reproduced in 5.12.0-rc3+ too. > > There are use-after-free crashes in nilfs_mdt_destroy in fs/nilfs2/mdt.c. > > and there is a latest crash logs as follows: > > == > BUG: KASAN: use-after-free in nilfs_mdt_destroy+0x6f/0x80 fs/nilfs2/mdt.c:485 > Read of size 8 at addr 8880478f0098 by task syz-executor325/8480 > > CPU: 1 PID: 8480 Comm: syz-executor325 Not tainted 5.12.0-rc3+ #42 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS > 1.13.0-1ubuntu1 04/01/2014 > Call Trace: > __dump_stack lib/dump_stack.c:79 [inline] > dump_stack+0xfa/0x151 lib/dump_stack.c:120 > print_address_description.constprop.0.cold+0x82/0x32c mm/kasan/report.c:232 > __kasan_report mm/kasan/report.c:399 [inline] > kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:416 > nilfs_mdt_destroy+0x6f/0x80 fs/nilfs2/mdt.c:485 > nilfs_free_inode+0x3e/0x60 fs/nilfs2/super.c:167 > i_callback+0x3f/0x70 fs/inode.c:223 > alloc_inode+0x13e/0x1e0 fs/inode.c:248 > iget5_locked fs/inode.c:1148 [inline] > iget5_locked+0x57/0xd0 fs/inode.c:1141 > nilfs_iget_locked fs/nilfs2/inode.c:570 [inline] > nilfs_iget+0xb2/0x870 fs/nilfs2/inode.c:579 > nilfs_lookup fs/nilfs2/namei.c:63 [inline] > nilfs_lookup+0xfd/0x130 fs/nilfs2/namei.c:54 > __lookup_slow+0x255/0x490 fs/namei.c:1626 > lookup_slow fs/namei.c:1643 [inline] > walk_component+0x418/0x6a0 fs/namei.c:1939 > link_path_walk.part.0+0x6b6/0xc10 fs/namei.c:2266 > link_path_walk fs/namei.c:2190 [inline] > path_lookupat.isra.0+0x8d/0x530 fs/namei.c:2419 > filename_lookup+0x1a3/0x3e0 fs/namei.c:2453 > user_path_at include/linux/namei.h:60 [inline] > vfs_statx+0x13c/0x370 fs/stat.c:195 > do_statx+0xd9/0x160 fs/stat.c:590 > __do_sys_statx fs/stat.c:613 [inline] > __se_sys_statx fs/stat.c:608 [inline] > __x64_sys_statx+0xba/0x150 fs/stat.c:608 > do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 > entry_SYSCALL_64_after_hwframe+0x44/0xae > RIP: 0033:0x4505ad > Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 > 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d > 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 > RSP: 002b:7fff7db857c8 EFLAGS: 0246 ORIG_RAX: 014c > RAX: ffda RBX: RCX: 004505ad > RDX: RSI: 2040 RDI: 0006 > RBP: 0004 R08: R09: 004a4099 > R10: R11: 0246 R12: 7fff7db857ec > R13: 7fff7db85810 R14: 7fff7db857f0 R15: 0010 > > Allocated by task 8426: > kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 > kasan_set_track mm/kasan/common.c:46 [inline] > set_alloc_info mm/kasan/common.c:427 [inline] > kasan_kmalloc mm/kasan/common.c:506 [inline] > kasan_kmalloc mm/kasan/common.c:465 [inline] > __kasan_kmalloc+0x99/0xc0 mm/kasan/common.c:515 > kasan_kmalloc include/linux/kasan.h:233 [inline] > __kmalloc+0x1c7/0x3d0 mm/slub.c:4055 > kmalloc include/linux/slab.h:559 [inline] > kzalloc include/linux/slab.h:684 [inline] > nilfs_mdt_init+0x2c/0x1e0 fs/nilfs2/mdt.c:448 > nilfs_dat_read+0x11b/0x2c0 fs/nilfs2/dat.c:489 > nilfs_load_super_root fs/nilfs2/the_nilfs.c:120 [inline] > load_nilfs+0x327/0x11c0 fs/nilfs2/the_nilfs.c:269 > nilfs_fill_super fs/nilfs2/super.c:1058 [inline] > nilfs_mount+0xab0/0xfe0 fs/nilfs2/super.c:1316 > legacy_get_tree+0x105/0x220 fs/fs_context.c:592 > vfs_get_tree+0x89/0x2f0 fs/super.c:1497 > do_new_mount fs/namespace.c:2903 [inline] > path_mount+0x123b/0x1cc0 fs/namespace.c:3233 > do_mount+0xf3/0x110 fs/namespace.c:3246 > __do_sys_mount fs/namespace.c:3454 [inline] > __se_sys_mount fs/namespace.c:3431 [inline] > __x64_sys_mount+0x18f/0x230 fs/namespace.c:3431 > do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 > entry_SYSCALL_64_after_hwframe+0x44/0xae > > Last potentially related work creation: > kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 > kasan_record_aux_stack+0xe5/0x110 mm/kasan/generic.c:345 > __call_rcu kernel/rcu/tree.c:3039 [inline] > call_rcu+0xb1/0x700 kernel/rcu/tree.c:3114 > netlink_release+0xd41/0x1c20 net/netlink/af_netlink.c:810 > __sock_release+0xcd/0x280 net/socket.c:599 > sock_close+0x18/0x20 net/socket.c:1258 > __fput+0x288/0x920 fs/file_table.c:280 > task_work_run+0xe0/0
Re: [PATCH] fs/nilfs2: fix misspellings using codespell tool
Applied, thank you. Ryusuke Konishi On Thu, Mar 18, 2021 at 8:32 PM wrote: > > From: Liu xuzhi > > Two typos are found out by codespell tool \ > in 2217th and 2254th lines of segment.c: > > $ codespell ./fs/nilfs2/ > ./segment.c:2217 :retured ==> returned > ./segment.c:2254: retured ==> returned > > Fix two typos found by codespell. > > Signed-off-by: Liu xuzhi > --- > fs/nilfs2/segment.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index cd4da9535aed..686c8ee7b29c 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -2214,7 +2214,7 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info > *sci, int err) > * nilfs_construct_segment - construct a logical segment > * @sb: super block > * > - * Return Value: On success, 0 is retured. On errors, one of the following > + * Return Value: On success, 0 is returned. On errors, one of the following > * negative error code is returned. > * > * %-EROFS - Read only filesystem. > @@ -2251,7 +2251,7 @@ int nilfs_construct_segment(struct super_block *sb) > * @start: start byte offset > * @end: end byte offset (inclusive) > * > - * Return Value: On success, 0 is retured. On errors, one of the following > + * Return Value: On success, 0 is returned. On errors, one of the following > * negative error code is returned. > * > * %-EROFS - Read only filesystem. > -- > 2.25.1 >
Re: [PATCH] nilfs2: make splice write available again
Hi Andrew, Please send this to upstream. This fixes a regression of splice() on nilfs2. Thanks, Ryusuke Konishi On Mon, Feb 8, 2021 at 8:35 PM Ryusuke Konishi wrote: > > From: Joachim Henke > > Since 5.10, splice() or sendfile() to NILFS2 return EINVAL. This was > caused by commit 36e2c7421f02 ("fs: don't allow splice read/write > without explicit ops"). > > This patch initializes the splice_write field in file_operations, like > most file systems do, to restore the functionality. > > Signed-off-by: Joachim Henke > Signed-off-by: Ryusuke Konishi > Tested-by: Ryusuke Konishi > Cc: sta...@vger.kernel.org # 5.10+ > --- > fs/nilfs2/file.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c > index 64bc81363c6c..e1bd592ce700 100644 > --- a/fs/nilfs2/file.c > +++ b/fs/nilfs2/file.c > @@ -141,6 +141,7 @@ static int nilfs_file_mmap(struct file *file, struct > vm_area_struct *vma) > /* .release = nilfs_release_file, */ > .fsync = nilfs_sync_file, > .splice_read= generic_file_splice_read, > + .splice_write = iter_file_splice_write, > }; > > const struct inode_operations nilfs_file_inode_operations = { > -- > 1.8.3.1 >
[PATCH] nilfs2: make splice write available again
From: Joachim Henke Since 5.10, splice() or sendfile() to NILFS2 return EINVAL. This was caused by commit 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops"). This patch initializes the splice_write field in file_operations, like most file systems do, to restore the functionality. Signed-off-by: Joachim Henke Signed-off-by: Ryusuke Konishi Tested-by: Ryusuke Konishi Cc: sta...@vger.kernel.org # 5.10+ --- fs/nilfs2/file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index 64bc81363c6c..e1bd592ce700 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -141,6 +141,7 @@ static int nilfs_file_mmap(struct file *file, struct vm_area_struct *vma) /* .release = nilfs_release_file, */ .fsync = nilfs_sync_file, .splice_read= generic_file_splice_read, + .splice_write = iter_file_splice_write, }; const struct inode_operations nilfs_file_inode_operations = { -- 1.8.3.1
Re: [PATCH] fs/nilfs2: remove some unused macros to tame gcc
Hi Andrew, Please queue this, a gcc warning fix, for the next merge window. Thanks, Ryusuke Konishi On Thu, Dec 10, 2020 at 7:25 AM Ryusuke Konishi wrote: > > From: Alex Shi > > There some macros are unused and cause gcc warning. Remove them. > > fs/nilfs2/segment.c:137:0: warning: macro "nilfs_cnt32_gt" is not used > [-Wunused-macros] > fs/nilfs2/segment.c:144:0: warning: macro "nilfs_cnt32_le" is not used > [-Wunused-macros] > fs/nilfs2/segment.c:143:0: warning: macro "nilfs_cnt32_lt" is not used > [-Wunused-macros] > > Signed-off-by: Alex Shi > Signed-off-by: Ryusuke Konishi > --- > fs/nilfs2/segment.c | 5 - > 1 file changed, 5 deletions(-) > > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index e3726aca28ed..cd4da9535aed 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -134,14 +134,9 @@ struct nilfs_sc_operations { > static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *); > static void nilfs_dispose_list(struct the_nilfs *, struct list_head *, int); > > -#define nilfs_cnt32_gt(a, b) \ > - (typecheck(__u32, a) && typecheck(__u32, b) && \ > -((__s32)(b) - (__s32)(a) < 0)) > #define nilfs_cnt32_ge(a, b) \ > (typecheck(__u32, a) && typecheck(__u32, b) && \ > ((__s32)(a) - (__s32)(b) >= 0)) > -#define nilfs_cnt32_lt(a, b) nilfs_cnt32_gt(b, a) > -#define nilfs_cnt32_le(a, b) nilfs_cnt32_ge(b, a) > > static int nilfs_prepare_segment_lock(struct super_block *sb, > struct nilfs_transaction_info *ti) > -- > 1.8.3.1 >
[PATCH] fs/nilfs2: remove some unused macros to tame gcc
From: Alex Shi There some macros are unused and cause gcc warning. Remove them. fs/nilfs2/segment.c:137:0: warning: macro "nilfs_cnt32_gt" is not used [-Wunused-macros] fs/nilfs2/segment.c:144:0: warning: macro "nilfs_cnt32_le" is not used [-Wunused-macros] fs/nilfs2/segment.c:143:0: warning: macro "nilfs_cnt32_lt" is not used [-Wunused-macros] Signed-off-by: Alex Shi Signed-off-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 5 - 1 file changed, 5 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index e3726aca28ed..cd4da9535aed 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -134,14 +134,9 @@ struct nilfs_sc_operations { static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *); static void nilfs_dispose_list(struct the_nilfs *, struct list_head *, int); -#define nilfs_cnt32_gt(a, b) \ - (typecheck(__u32, a) && typecheck(__u32, b) && \ -((__s32)(b) - (__s32)(a) < 0)) #define nilfs_cnt32_ge(a, b) \ (typecheck(__u32, a) && typecheck(__u32, b) && \ ((__s32)(a) - (__s32)(b) >= 0)) -#define nilfs_cnt32_lt(a, b) nilfs_cnt32_gt(b, a) -#define nilfs_cnt32_le(a, b) nilfs_cnt32_ge(b, a) static int nilfs_prepare_segment_lock(struct super_block *sb, struct nilfs_transaction_info *ti) -- 1.8.3.1
Re: [PATCH] nilfs2: Fix some kernel-doc warnings for nilfs2
Hi Andrew, Please queue this, kernel-doc warnings fix, for the next merge window. Thanks, Ryusuke Konishi On Tue, Sep 29, 2020 at 10:31 PM Ryusuke Konishi wrote: > > From: Wang Hai > > Fixes the following W=1 kernel build warning(s): > > fs/nilfs2/bmap.c:378: warning: Excess function parameter 'bhp' description in > 'nilfs_bmap_assign' > fs/nilfs2/cpfile.c:907: warning: Excess function parameter 'status' > description in 'nilfs_cpfile_change_cpmode' > fs/nilfs2/cpfile.c:946: warning: Excess function parameter 'stat' description > in 'nilfs_cpfile_get_stat' > fs/nilfs2/page.c:76: warning: Excess function parameter 'inode' description > in 'nilfs_forget_buffer' > fs/nilfs2/sufile.c:563: warning: Excess function parameter 'stat' description > in 'nilfs_sufile_get_stat' > > Signed-off-by: Wang Hai > Signed-off-by: Ryusuke Konishi > --- > fs/nilfs2/bmap.c | 2 +- > fs/nilfs2/cpfile.c | 6 +++--- > fs/nilfs2/page.c | 1 - > fs/nilfs2/sufile.c | 4 ++-- > 4 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c > index e516ae389ca5..5900879d5693 100644 > --- a/fs/nilfs2/bmap.c > +++ b/fs/nilfs2/bmap.c > @@ -355,7 +355,7 @@ void nilfs_bmap_lookup_dirty_buffers(struct nilfs_bmap > *bmap, > /** > * nilfs_bmap_assign - assign a new block number to a block > * @bmap: bmap > - * @bhp: pointer to buffer head > + * @bh: pointer to buffer head > * @blocknr: block number > * @binfo: block information > * > diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c > index 86d4d850d130..025fb082575a 100644 > --- a/fs/nilfs2/cpfile.c > +++ b/fs/nilfs2/cpfile.c > @@ -889,7 +889,7 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 > cno) > * nilfs_cpfile_change_cpmode - change checkpoint mode > * @cpfile: inode of checkpoint file > * @cno: checkpoint number > - * @status: mode of checkpoint > + * @mode: mode of checkpoint > * > * Description: nilfs_change_cpmode() changes the mode of the checkpoint > * specified by @cno. The mode @mode is NILFS_CHECKPOINT or NILFS_SNAPSHOT. > @@ -930,12 +930,12 @@ int nilfs_cpfile_change_cpmode(struct inode *cpfile, > __u64 cno, int mode) > /** > * nilfs_cpfile_get_stat - get checkpoint statistics > * @cpfile: inode of checkpoint file > - * @stat: pointer to a structure of checkpoint statistics > + * @cpstat: pointer to a structure of checkpoint statistics > * > * Description: nilfs_cpfile_get_stat() returns information about > checkpoints. > * > * Return Value: On success, 0 is returned, and checkpoints information is > - * stored in the place pointed by @stat. On error, one of the following > + * stored in the place pointed by @cpstat. On error, one of the following > * negative error codes is returned. > * > * %-EIO - I/O error. > diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c > index b175f1330408..171fb5cd427f 100644 > --- a/fs/nilfs2/page.c > +++ b/fs/nilfs2/page.c > @@ -69,7 +69,6 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode, > > /** > * nilfs_forget_buffer - discard dirty state > - * @inode: owner inode of the buffer > * @bh: buffer head of the buffer to be discarded > */ > void nilfs_forget_buffer(struct buffer_head *bh) > diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c > index 42ff67c0c14f..63722475e17e 100644 > --- a/fs/nilfs2/sufile.c > +++ b/fs/nilfs2/sufile.c > @@ -546,13 +546,13 @@ int nilfs_sufile_set_segment_usage(struct inode > *sufile, __u64 segnum, > /** > * nilfs_sufile_get_stat - get segment usage statistics > * @sufile: inode of segment usage file > - * @stat: pointer to a structure of segment usage statistics > + * @sustat: pointer to a structure of segment usage statistics > * > * Description: nilfs_sufile_get_stat() returns information about segment > * usage. > * > * Return Value: On success, 0 is returned, and segment usage information is > - * stored in the place pointed by @stat. On error, one of the following > + * stored in the place pointed by @sustat. On error, one of the following > * negative error codes is returned. > * > * %-EIO - I/O error. > -- > 1.8.3.1 >
[PATCH] nilfs2: Fix some kernel-doc warnings for nilfs2
From: Wang Hai Fixes the following W=1 kernel build warning(s): fs/nilfs2/bmap.c:378: warning: Excess function parameter 'bhp' description in 'nilfs_bmap_assign' fs/nilfs2/cpfile.c:907: warning: Excess function parameter 'status' description in 'nilfs_cpfile_change_cpmode' fs/nilfs2/cpfile.c:946: warning: Excess function parameter 'stat' description in 'nilfs_cpfile_get_stat' fs/nilfs2/page.c:76: warning: Excess function parameter 'inode' description in 'nilfs_forget_buffer' fs/nilfs2/sufile.c:563: warning: Excess function parameter 'stat' description in 'nilfs_sufile_get_stat' Signed-off-by: Wang Hai Signed-off-by: Ryusuke Konishi --- fs/nilfs2/bmap.c | 2 +- fs/nilfs2/cpfile.c | 6 +++--- fs/nilfs2/page.c | 1 - fs/nilfs2/sufile.c | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index e516ae389ca5..5900879d5693 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -355,7 +355,7 @@ void nilfs_bmap_lookup_dirty_buffers(struct nilfs_bmap *bmap, /** * nilfs_bmap_assign - assign a new block number to a block * @bmap: bmap - * @bhp: pointer to buffer head + * @bh: pointer to buffer head * @blocknr: block number * @binfo: block information * diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c index 86d4d850d130..025fb082575a 100644 --- a/fs/nilfs2/cpfile.c +++ b/fs/nilfs2/cpfile.c @@ -889,7 +889,7 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno) * nilfs_cpfile_change_cpmode - change checkpoint mode * @cpfile: inode of checkpoint file * @cno: checkpoint number - * @status: mode of checkpoint + * @mode: mode of checkpoint * * Description: nilfs_change_cpmode() changes the mode of the checkpoint * specified by @cno. The mode @mode is NILFS_CHECKPOINT or NILFS_SNAPSHOT. @@ -930,12 +930,12 @@ int nilfs_cpfile_change_cpmode(struct inode *cpfile, __u64 cno, int mode) /** * nilfs_cpfile_get_stat - get checkpoint statistics * @cpfile: inode of checkpoint file - * @stat: pointer to a structure of checkpoint statistics + * @cpstat: pointer to a structure of checkpoint statistics * * Description: nilfs_cpfile_get_stat() returns information about checkpoints. * * Return Value: On success, 0 is returned, and checkpoints information is - * stored in the place pointed by @stat. On error, one of the following + * stored in the place pointed by @cpstat. On error, one of the following * negative error codes is returned. * * %-EIO - I/O error. diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index b175f1330408..171fb5cd427f 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -69,7 +69,6 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode, /** * nilfs_forget_buffer - discard dirty state - * @inode: owner inode of the buffer * @bh: buffer head of the buffer to be discarded */ void nilfs_forget_buffer(struct buffer_head *bh) diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c index 42ff67c0c14f..63722475e17e 100644 --- a/fs/nilfs2/sufile.c +++ b/fs/nilfs2/sufile.c @@ -546,13 +546,13 @@ int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum, /** * nilfs_sufile_get_stat - get segment usage statistics * @sufile: inode of segment usage file - * @stat: pointer to a structure of segment usage statistics + * @sustat: pointer to a structure of segment usage statistics * * Description: nilfs_sufile_get_stat() returns information about segment * usage. * * Return Value: On success, 0 is returned, and segment usage information is - * stored in the place pointed by @stat. On error, one of the following + * stored in the place pointed by @sustat. On error, one of the following * negative error codes is returned. * * %-EIO - I/O error. -- 1.8.3.1
Re: [PATCH -next] nilfs2: Fix some kernel-doc warnings for nilfs2
Hi Wang, The patch looks correct. Will apply, thank you. Ryusuke Konishi On Fri, Sep 18, 2020 at 9:40 PM Wang Hai wrote: > > Fixes the following W=1 kernel build warning(s): > > fs/nilfs2/bmap.c:378: warning: Excess function parameter 'bhp' description in > 'nilfs_bmap_assign' > fs/nilfs2/cpfile.c:907: warning: Excess function parameter 'status' > description in 'nilfs_cpfile_change_cpmode' > fs/nilfs2/cpfile.c:946: warning: Excess function parameter 'stat' description > in 'nilfs_cpfile_get_stat' > fs/nilfs2/page.c:76: warning: Excess function parameter 'inode' description > in 'nilfs_forget_buffer' > fs/nilfs2/sufile.c:563: warning: Excess function parameter 'stat' description > in 'nilfs_sufile_get_stat' > > Signed-off-by: Wang Hai > --- > fs/nilfs2/bmap.c | 2 +- > fs/nilfs2/cpfile.c | 6 +++--- > fs/nilfs2/page.c | 1 - > fs/nilfs2/sufile.c | 4 ++-- > 4 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c > index e516ae389ca5..5900879d5693 100644 > --- a/fs/nilfs2/bmap.c > +++ b/fs/nilfs2/bmap.c > @@ -355,7 +355,7 @@ void nilfs_bmap_lookup_dirty_buffers(struct nilfs_bmap > *bmap, > /** > * nilfs_bmap_assign - assign a new block number to a block > * @bmap: bmap > - * @bhp: pointer to buffer head > + * @bh: pointer to buffer head > * @blocknr: block number > * @binfo: block information > * > diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c > index 86d4d850d130..025fb082575a 100644 > --- a/fs/nilfs2/cpfile.c > +++ b/fs/nilfs2/cpfile.c > @@ -889,7 +889,7 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 > cno) > * nilfs_cpfile_change_cpmode - change checkpoint mode > * @cpfile: inode of checkpoint file > * @cno: checkpoint number > - * @status: mode of checkpoint > + * @mode: mode of checkpoint > * > * Description: nilfs_change_cpmode() changes the mode of the checkpoint > * specified by @cno. The mode @mode is NILFS_CHECKPOINT or NILFS_SNAPSHOT. > @@ -930,12 +930,12 @@ int nilfs_cpfile_change_cpmode(struct inode *cpfile, > __u64 cno, int mode) > /** > * nilfs_cpfile_get_stat - get checkpoint statistics > * @cpfile: inode of checkpoint file > - * @stat: pointer to a structure of checkpoint statistics > + * @cpstat: pointer to a structure of checkpoint statistics > * > * Description: nilfs_cpfile_get_stat() returns information about > checkpoints. > * > * Return Value: On success, 0 is returned, and checkpoints information is > - * stored in the place pointed by @stat. On error, one of the following > + * stored in the place pointed by @cpstat. On error, one of the following > * negative error codes is returned. > * > * %-EIO - I/O error. > diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c > index b175f1330408..171fb5cd427f 100644 > --- a/fs/nilfs2/page.c > +++ b/fs/nilfs2/page.c > @@ -69,7 +69,6 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode, > > /** > * nilfs_forget_buffer - discard dirty state > - * @inode: owner inode of the buffer > * @bh: buffer head of the buffer to be discarded > */ > void nilfs_forget_buffer(struct buffer_head *bh) > diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c > index 42ff67c0c14f..63722475e17e 100644 > --- a/fs/nilfs2/sufile.c > +++ b/fs/nilfs2/sufile.c > @@ -546,13 +546,13 @@ int nilfs_sufile_set_segment_usage(struct inode > *sufile, __u64 segnum, > /** > * nilfs_sufile_get_stat - get segment usage statistics > * @sufile: inode of segment usage file > - * @stat: pointer to a structure of segment usage statistics > + * @sustat: pointer to a structure of segment usage statistics > * > * Description: nilfs_sufile_get_stat() returns information about segment > * usage. > * > * Return Value: On success, 0 is returned, and segment usage information is > - * stored in the place pointed by @stat. On error, one of the following > + * stored in the place pointed by @sustat. On error, one of the following > * negative error codes is returned. > * > * %-EIO - I/O error. > -- > 2.17.1 >
Re: [PATCH] nilfs2: only call unlock_new_inode() if I_NEW
Yeah, I sent this to Andrew a little while ago: https://lkml.org/lkml/2020/7/27/976 Thanks, Ryusuke Konishi On Tue, Jul 28, 2020 at 1:50 AM Eric Biggers wrote: > > On Sun, Jun 28, 2020 at 12:01:52AM -0700, Eric Biggers wrote: > > From: Eric Biggers > > > > unlock_new_inode() is only meant to be called after a new inode has > > already been inserted into the hash table. But nilfs_new_inode() can > > call it even before it has inserted the inode, triggering the WARNING in > > unlock_new_inode(). Fix this by only calling unlock_new_inode() if the > > inode has the I_NEW flag set, indicating that it's in the table. > > > > Signed-off-by: Eric Biggers > > Ping. Ryusuke, any interest in taking this patch? > > - Eric
[PATCH 2/3] nilfs2: Convert __nilfs_msg to integrate the level and format
From: Joe Perches Reduce object size a bit by removing the KERN_ as a separate argument and adding it to the format string. Reduce overall object size by about ~.5% (x86-64 defconfig w/ nilfs2) old: $ size -t fs/nilfs2/built-in.a | tail -1 1917388676 44 200458 30f0a (TOTALS) new: $ size -t fs/nilfs2/built-in.a | tail -1 1909718676 44 199691 30c0b (TOTALS) Signed-off-by: Joe Perches Signed-off-by: Ryusuke Konishi --- fs/nilfs2/nilfs.h | 9 - fs/nilfs2/super.c | 16 +++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 42395ba52da6..979a41016743 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h @@ -289,9 +289,8 @@ static inline int nilfs_mark_inode_dirty_sync(struct inode *inode) /* super.c */ extern struct inode *nilfs_alloc_inode(struct super_block *); -extern __printf(3, 4) -void __nilfs_msg(struct super_block *sb, const char *level, -const char *fmt, ...); +__printf(2, 3) +void __nilfs_msg(struct super_block *sb, const char *fmt, ...); extern __printf(3, 4) void __nilfs_error(struct super_block *sb, const char *function, const char *fmt, ...); @@ -299,7 +298,7 @@ void __nilfs_error(struct super_block *sb, const char *function, #ifdef CONFIG_PRINTK #define nilfs_msg(sb, level, fmt, ...) \ - __nilfs_msg(sb, level, fmt, ##__VA_ARGS__) + __nilfs_msg(sb, level fmt, ##__VA_ARGS__) #define nilfs_error(sb, fmt, ...) \ __nilfs_error(sb, __func__, fmt, ##__VA_ARGS__) @@ -307,7 +306,7 @@ void __nilfs_error(struct super_block *sb, const char *function, #define nilfs_msg(sb, level, fmt, ...) \ do {\ - no_printk(fmt, ##__VA_ARGS__); \ + no_printk(level fmt, ##__VA_ARGS__);\ (void)(sb); \ } while (0) #define nilfs_error(sb, fmt, ...) \ diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 5729ee86da9a..fef4821a1f0f 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -62,19 +62,25 @@ static int nilfs_setup_super(struct super_block *sb, int is_mount); static int nilfs_remount(struct super_block *sb, int *flags, char *data); -void __nilfs_msg(struct super_block *sb, const char *level, const char *fmt, -...) +void __nilfs_msg(struct super_block *sb, const char *fmt, ...) { struct va_format vaf; va_list args; + int level; va_start(args, fmt); - vaf.fmt = fmt; + + level = printk_get_level(fmt); + vaf.fmt = printk_skip_level(fmt); vaf.va = + if (sb) - printk("%sNILFS (%s): %pV\n", level, sb->s_id, ); + printk("%c%cNILFS (%s): %pV\n", + KERN_SOH_ASCII, level, sb->s_id, ); else - printk("%sNILFS: %pV\n", level, ); + printk("%c%cNILFS: %pV\n", + KERN_SOH_ASCII, level, ); + va_end(args); } -- 1.8.3.1
[PATCH 0/3] nilfs2 updates
Hi Andrew, Please queue the following changes for the next merge window: Eric Biggers (1): nilfs2: only call unlock_new_inode() if I_NEW Joe Perches (2): nilfs2: Convert __nilfs_msg to integrate the level and format nilfs2: Use a more common logging style In this series, > nilfs2: only call unlock_new_inode() if I_NEW fixes wrong unlock_new_inode() call and related WARNING which can be triggered from error paths of nilfs_new_inode(). > nilfs2: Convert __nilfs_msg to integrate the level and format > nilfs2: Use a more common logging style reduce object size and use more common kernel logging styles. Thanks, Ryusuke Konishi -- fs/nilfs2/alloc.c | 38 +++ fs/nilfs2/btree.c | 42 - fs/nilfs2/cpfile.c| 10 +++--- fs/nilfs2/dat.c | 14 - fs/nilfs2/direct.c| 14 + fs/nilfs2/gcinode.c | 2 +- fs/nilfs2/ifile.c | 4 +-- fs/nilfs2/inode.c | 32 +-- fs/nilfs2/ioctl.c | 37 +++--- fs/nilfs2/mdt.c | 2 +- fs/nilfs2/namei.c | 6 ++-- fs/nilfs2/nilfs.h | 18 --- fs/nilfs2/page.c | 11 +++ fs/nilfs2/recovery.c | 32 +-- fs/nilfs2/segbuf.c| 2 +- fs/nilfs2/segment.c | 38 +++ fs/nilfs2/sufile.c| 29 -- fs/nilfs2/super.c | 73 ++- fs/nilfs2/sysfs.c | 29 -- fs/nilfs2/the_nilfs.c | 85 --- 20 files changed, 256 insertions(+), 262 deletions(-) -- 1.8.3.1
[PATCH 3/3] nilfs2: Use a more common logging style
From: Joe Perches Add macros for nilfs_(sb, fmt, ...) and convert the uses of 'nilfs_msg(sb, KERN_, ...)' to 'nilfs_(sb, ...)' so nilfs2 uses a logging style more like the typical kernel logging style. Miscellanea: o Realign arguments for these uses Signed-off-by: Joe Perches Signed-off-by: Ryusuke Konishi --- fs/nilfs2/alloc.c | 38 +++ fs/nilfs2/btree.c | 42 - fs/nilfs2/cpfile.c| 10 +++--- fs/nilfs2/dat.c | 14 - fs/nilfs2/direct.c| 14 + fs/nilfs2/gcinode.c | 2 +- fs/nilfs2/ifile.c | 4 +-- fs/nilfs2/inode.c | 29 +- fs/nilfs2/ioctl.c | 37 +++--- fs/nilfs2/mdt.c | 2 +- fs/nilfs2/namei.c | 6 ++-- fs/nilfs2/nilfs.h | 9 ++ fs/nilfs2/page.c | 11 +++ fs/nilfs2/recovery.c | 32 +-- fs/nilfs2/segbuf.c| 2 +- fs/nilfs2/segment.c | 38 +++ fs/nilfs2/sufile.c| 29 -- fs/nilfs2/super.c | 57 -- fs/nilfs2/sysfs.c | 29 -- fs/nilfs2/the_nilfs.c | 85 --- 20 files changed, 239 insertions(+), 251 deletions(-) diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c index 235b959fc2b3..adf3bb0a8048 100644 --- a/fs/nilfs2/alloc.c +++ b/fs/nilfs2/alloc.c @@ -613,10 +613,10 @@ void nilfs_palloc_commit_free_entry(struct inode *inode, lock = nilfs_mdt_bgl_lock(inode, group); if (!nilfs_clear_bit_atomic(lock, group_offset, bitmap)) - nilfs_msg(inode->i_sb, KERN_WARNING, - "%s (ino=%lu): entry number %llu already freed", - __func__, inode->i_ino, - (unsigned long long)req->pr_entry_nr); + nilfs_warn(inode->i_sb, + "%s (ino=%lu): entry number %llu already freed", + __func__, inode->i_ino, + (unsigned long long)req->pr_entry_nr); else nilfs_palloc_group_desc_add_entries(desc, lock, 1); @@ -654,10 +654,10 @@ void nilfs_palloc_abort_alloc_entry(struct inode *inode, lock = nilfs_mdt_bgl_lock(inode, group); if (!nilfs_clear_bit_atomic(lock, group_offset, bitmap)) - nilfs_msg(inode->i_sb, KERN_WARNING, - "%s (ino=%lu): entry number %llu already freed", - __func__, inode->i_ino, - (unsigned long long)req->pr_entry_nr); + nilfs_warn(inode->i_sb, + "%s (ino=%lu): entry number %llu already freed", + __func__, inode->i_ino, + (unsigned long long)req->pr_entry_nr); else nilfs_palloc_group_desc_add_entries(desc, lock, 1); @@ -763,10 +763,10 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems) do { if (!nilfs_clear_bit_atomic(lock, group_offset, bitmap)) { - nilfs_msg(inode->i_sb, KERN_WARNING, - "%s (ino=%lu): entry number %llu already freed", - __func__, inode->i_ino, - (unsigned long long)entry_nrs[j]); + nilfs_warn(inode->i_sb, + "%s (ino=%lu): entry number %llu already freed", + __func__, inode->i_ino, + (unsigned long long)entry_nrs[j]); } else { n++; } @@ -808,10 +808,10 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems) ret = nilfs_palloc_delete_entry_block(inode, last_nrs[k]); if (ret && ret != -ENOENT) - nilfs_msg(inode->i_sb, KERN_WARNING, - "error %d deleting block that object (entry=%llu, ino=%lu) belongs to", - ret, (unsigned long long)last_nrs[k], - inode->i_ino); + nilfs_warn(inode->i_sb, + "error %d deleting block that object (entry=%llu, ino=%lu) belongs to", + ret, (unsigned long long)last_nrs[k], + inode->i_ino); } desc_kaddr = kmap_
[PATCH 1/3] nilfs2: only call unlock_new_inode() if I_NEW
From: Eric Biggers unlock_new_inode() is only meant to be called after a new inode has already been inserted into the hash table. But nilfs_new_inode() can call it even before it has inserted the inode, triggering the WARNING in unlock_new_inode(). Fix this by only calling unlock_new_inode() if the inode has the I_NEW flag set, indicating that it's in the table. Signed-off-by: Eric Biggers Signed-off-by: Ryusuke Konishi --- fs/nilfs2/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 28009ec54420..3318dd1350b2 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -388,7 +388,8 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode) failed_after_creation: clear_nlink(inode); - unlock_new_inode(inode); + if (inode->i_state & I_NEW) + unlock_new_inode(inode); iput(inode); /* * raw_inode will be deleted through * nilfs_evict_inode(). -- 1.8.3.1
[PATCH] nilfs2: fix null pointer dereference at nilfs_segctor_do_construct()
After commit c3aab9a0bd91 ("mm/filemap.c: don't initiate writeback if mapping has no dirty pages"), the following null pointer dereference has been reported on nilfs2: BUG: kernel NULL pointer dereference, address: 00a8 #PF: supervisor read access in kernel mode #PF: error_code(0x) - not-present page PGD 0 P4D 0 Oops: [#1] SMP PTI ... RIP: 0010:percpu_counter_add_batch+0xa/0x60 ... Call Trace: __test_set_page_writeback+0x2d3/0x330 nilfs_segctor_do_construct+0x10d3/0x2110 [nilfs2] nilfs_segctor_construct+0x168/0x260 [nilfs2] nilfs_segctor_thread+0x127/0x3b0 [nilfs2] kthread+0xf8/0x130 ... This crash turned out to be caused by set_page_writeback() call for segment summary buffers at nilfs_segctor_prepare_write(). set_page_writeback() can call inc_wb_stat(inode_to_wb(inode), WB_WRITEBACK) where inode_to_wb(inode) is NULL if the inode of underlying block device does not have an associated wb. This fixes the issue by calling inode_attach_wb() in advance to ensure to associate the bdev inode with its wb. Reported-by: Walton Hoops Reported-by: Tomas Hlavaty Reported-by: ARAI Shun-ichi Reported-by: Hideki EIRAKU Signed-off-by: Ryusuke Konishi Tested-by: Ryusuke Konishi Cc: sta...@vger.kernel.org # v5.4+ --- fs/nilfs2/segment.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 445eef4..91b58c8 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -2780,6 +2780,8 @@ int nilfs_attach_log_writer(struct super_block *sb, struct nilfs_root *root) if (!nilfs->ns_writer) return -ENOMEM; + inode_attach_wb(nilfs->ns_bdev->bd_inode, NULL); + err = nilfs_segctor_start_thread(nilfs->ns_writer); if (err) { kfree(nilfs->ns_writer); -- 1.8.3.1
Re: BUG: unable to handle kernel NULL pointer dereference at 00000000000000a8 in nilfs_segctor_do_co
> Wondering if it can be reproduced on mainline with c3aab9a0bd91 > ("mm/filemap.c: dont initiate writeback if mapping has no dirty pages") > reverted? For mainline kernels with that commit reverted, this oops actually doesn't occur. Regards, Ryusuke Konishi On Mon, Jun 1, 2020 at 11:40 AM Hillf Danton wrote: > On Mon, 01 Jun 2020 02:49:54 Ryusuke Konishi wrote: > > Hi, > > > > This bug turned out to be caused by set_page_writeback() call for > > segment summary buffers and super root buffers at > > nilfs_segctor_prepare_write(). > > > > set_page_writeback() can call inc_wb_stat(inode_to_wb(inode), > > WB_WRIEBACK) where inode_to_wb(inode) is NULL if inode_attach_wb() is > > not called in advance. To ensure inode_attach_wb() is called, > > mark_buffer_dirty() should be called for those buffers. > > > > The following patch fixes this issue, > > Thanks for sharing your analysis and patch. > > Wondering if it can be reproduced on mainline with c3aab9a0bd91 > ("mm/filemap.c: dont initiate writeback if mapping has no dirty pages") > reverted? If no then we need to update the stable trees. > > Hillf > > > but I got another oops at > > nilfs_segctor_complete_write() during a stress test. So, I'm still > > investigating. > > > > Regards, > > Ryusuke Konishi > > > > === > > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > > index 445eef4..f6b5ca8 100644 > > --- a/fs/nilfs2/segment.c > > +++ b/fs/nilfs2/segment.c > > @@ -1650,6 +1650,8 @@ static void nilfs_segctor_prepare_write(struct > > nilfs_sc_info *sci) > > > > list_for_each_entry(bh, >sb_segsum_buffers, > > b_assoc_buffers) { > > + set_buffer_uptodate(bh); > > + mark_buffer_dirty(bh); > > if (bh->b_page != bd_page) { > > if (bd_page) { > > lock_page(bd_page); > > @@ -1665,6 +1667,8 @@ static void nilfs_segctor_prepare_write(struct > > nilfs_sc_info *sci) > > b_assoc_buffers) { > > set_buffer_async_write(bh); > > if (bh == segbuf->sb_super_root) { > > + set_buffer_uptodate(bh); > > + mark_buffer_dirty(bh); > > if (bh->b_page != bd_page) { > > lock_page(bd_page); > > clear_page_dirty_for_io(bd_page); > > === > > > > > > On Thu, 30 Apr 2020 08:27:47 -0700, Tom wrote: > > > Thank you! This is very helpful information, and does seem to be a > > > workaround. > > > > > > Like you, I have my home directory on a separate NILFS2 filesystem. As > > > a temporary solution, I removed the line from /etc/fstab for that > > > filesystem and added your dd suggestion along with a manual mount of > > > the home filesystem to /etc/rc.local. /home is now mounted properly > > > at boot with any of the newer kernels I tried. > > > > > > Thanks, > > > Tom > > > > > > On 4/30/20 5:38 AM, Hideki EIRAKU wrote: > > >>> In Msg <874kuapb2s@logand.com>; > > >>> Subject "Re: BUG: unable to handle kernel NULL pointer dereference > > >>> at > > >>> 00a8 in nilfs_segctor_do_construct": > > >>> > > >>>> Tomas Hlavaty writes: > > >>>>>>> 2) Can you mount the corrupted(?) partition from a recent version of > > >>>>>>> kernel ? > > >>>> > > >>>> I tried the following Linux kernel versions: > > >>>> > > >>>> - v4.19 > > >>>> - v5.4 > > >>>> - v5.5.11 > > >>>> > > >>>> and still get the crash > > >> I found conditions to reproduce this issue with Linux 5.7-rc3: > > >> - CONFIG_MEMCG=y *and* CONFIG_BLK_CGROUP=y > > >> - When the NILFS2 file system writes to a device, the device file has > > >>never written by other programs since boot > > >> The following is an example with CONFIG_MEMCG=y and > > >> CONFIG_BLK_CGROUP=y kernel. If you do mkfs and mount it, it works > > >> because the mkfs command has written data to the device file before > > >> mounting: > > >> #
Re: BUG: unable to handle kernel NULL pointer dereference at 00000000000000a8 in nilfs_segctor_do_co
Hi, This bug turned out to be caused by set_page_writeback() call for segment summary buffers and super root buffers at nilfs_segctor_prepare_write(). set_page_writeback() can call inc_wb_stat(inode_to_wb(inode), WB_WRIEBACK) where inode_to_wb(inode) is NULL if inode_attach_wb() is not called in advance. To ensure inode_attach_wb() is called, mark_buffer_dirty() should be called for those buffers. The following patch fixes this issue, but I got another oops at nilfs_segctor_complete_write() during a stress test. So, I'm still investigating. Regards, Ryusuke Konishi === diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 445eef4..f6b5ca8 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -1650,6 +1650,8 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci) list_for_each_entry(bh, >sb_segsum_buffers, b_assoc_buffers) { + set_buffer_uptodate(bh); + mark_buffer_dirty(bh); if (bh->b_page != bd_page) { if (bd_page) { lock_page(bd_page); @@ -1665,6 +1667,8 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci) b_assoc_buffers) { set_buffer_async_write(bh); if (bh == segbuf->sb_super_root) { + set_buffer_uptodate(bh); + mark_buffer_dirty(bh); if (bh->b_page != bd_page) { lock_page(bd_page); clear_page_dirty_for_io(bd_page); === On Thu, 30 Apr 2020 08:27:47 -0700, Tom wrote: > Thank you! This is very helpful information, and does seem to be a > workaround. > > Like you, I have my home directory on a separate NILFS2 filesystem. As > a temporary solution, I removed the line from /etc/fstab for that > filesystem and added your dd suggestion along with a manual mount of > the home filesystem to /etc/rc.local. /home is now mounted properly > at boot with any of the newer kernels I tried. > > Thanks, > Tom > > On 4/30/20 5:38 AM, Hideki EIRAKU wrote: >>> In Msg <874kuapb2s@logand.com>; >>> Subject "Re: BUG: unable to handle kernel NULL pointer dereference at >>> 00a8 in nilfs_segctor_do_construct": >>> >>>> Tomas Hlavaty writes: >>>>>>> 2) Can you mount the corrupted(?) partition from a recent version of >>>>>>> kernel ? >>>> >>>> I tried the following Linux kernel versions: >>>> >>>> - v4.19 >>>> - v5.4 >>>> - v5.5.11 >>>> >>>> and still get the crash >> I found conditions to reproduce this issue with Linux 5.7-rc3: >> - CONFIG_MEMCG=y *and* CONFIG_BLK_CGROUP=y >> - When the NILFS2 file system writes to a device, the device file has >>never written by other programs since boot >> The following is an example with CONFIG_MEMCG=y and >> CONFIG_BLK_CGROUP=y kernel. If you do mkfs and mount it, it works >> because the mkfs command has written data to the device file before >> mounting: >> # mkfs -t nilfs2 /dev/sda1 >> mkfs.nilfs2 (nilfs-utils 2.2.7) >> Start writing file system initial data to the device >> Blocksize:4096 Device:/dev/sda1 Device Size:267386880 >> File system initialization succeeded !! >> # mount /dev/sda1 /mnt >> # touch /mnt >> # sync >> # >> Loopback mount seems to be the same - if you do losetup, mkfs and >> mount on a loopback device, it works: >> # losetup /dev/loop0 foo >> # mkfs -t nilfs2 /dev/loop0 >> mkfs.nilfs2 (nilfs-utils 2.2.7) >> Start writing file system initial data to the device >> Blocksize:4096 Device:/dev/loop0 Device Size:267386880 >> File system initialization succeeded !! >> # mount /dev/sda1 /mnt >> # touch /mnt >> # sync >> # >> But if you do mkfs on a file and use mount -o loop, it may fail, >> depending on whether the loopback device assigned by the mount command >> was used or not before mounting: >> # /sbin/mkfs.nilfs2 ./foo >> mkfs.nilfs2 (nilfs-utils 2.2.7) >> Start writing file system initial data to the device >> Blocksize:4096 Device:./foo Device Size:268435456 >> File system initialization succeeded !! >> # mount -o loop ./foo /mnt >> [ 36.371331] NILFS (loop0): segctord starting. Construction interval = >> 5 seconds, CP frequency < 30 seconds >> # touch /mnt >> # sync >> [ 40.252869] BUG: kernel
Re: [PATCH V2] nilfs2: Fix reference count leak in nilfs_sysfs_create_device_group
Hi Andrew, This v2 patch was not CC'ed to you. Could you please pick it up from LKML? Regards, Ryusuke Konishi On Thu, May 28, 2020 at 8:23 AM Ryusuke Konishi wrote: > > Hi Andrew, > > Please pick this up as well. > > Acked-by: Ryusuke Konishi > > On Thu, May 28, 2020 at 8:04 AM wrote: > > > > From: Qiushi Wu > > > > kobject_init_and_add() takes reference even when it fails. > > In nilfs_sysfs_create_device_group(), the memory allocated by > > kobject_init_and_add() is not freed when kobject_init_and_add() > > fails. Fix this issue by calling kobject_put() to clean up the > > kobject. > > > > Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/ group") > > Signed-off-by: Qiushi Wu > > --- > > V2: using kobject_put() to handle kobject_init_and_add() instead of > > kobject_del(). > > > > fs/nilfs2/sysfs.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c > > index e60be7bb55b0..8416f915d118 100644 > > --- a/fs/nilfs2/sysfs.c > > +++ b/fs/nilfs2/sysfs.c > > @@ -999,8 +999,10 @@ int nilfs_sysfs_create_device_group(struct super_block > > *sb) > > init_completion(>ns_dev_kobj_unregister); > > err = kobject_init_and_add(>ns_dev_kobj, _dev_ktype, > > NULL, > > "%s", sb->s_id); > > - if (err) > > + if (err) { > > + kobject_put(>ns_dev_kobj); > > goto free_dev_subgroups; > > + } > > > > err = nilfs_sysfs_create_mounted_snapshots_group(nilfs); > > if (err) > > -- > > 2.17.1 > >
Re: [PATCH V2] nilfs2: Fix reference count leak in nilfs_sysfs_create_device_group
Hi Andrew, Please pick this up as well. Acked-by: Ryusuke Konishi On Thu, May 28, 2020 at 8:04 AM wrote: > > From: Qiushi Wu > > kobject_init_and_add() takes reference even when it fails. > In nilfs_sysfs_create_device_group(), the memory allocated by > kobject_init_and_add() is not freed when kobject_init_and_add() > fails. Fix this issue by calling kobject_put() to clean up the > kobject. > > Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/ group") > Signed-off-by: Qiushi Wu > --- > V2: using kobject_put() to handle kobject_init_and_add() instead of > kobject_del(). > > fs/nilfs2/sysfs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c > index e60be7bb55b0..8416f915d118 100644 > --- a/fs/nilfs2/sysfs.c > +++ b/fs/nilfs2/sysfs.c > @@ -999,8 +999,10 @@ int nilfs_sysfs_create_device_group(struct super_block > *sb) > init_completion(>ns_dev_kobj_unregister); > err = kobject_init_and_add(>ns_dev_kobj, _dev_ktype, > NULL, > "%s", sb->s_id); > - if (err) > + if (err) { > + kobject_put(>ns_dev_kobj); > goto free_dev_subgroups; > + } > > err = nilfs_sysfs_create_mounted_snapshots_group(nilfs); > if (err) > -- > 2.17.1 >
Re: [PATCH] nilfs2: Fix reference count leak in nilfs_sysfs_create_device_group
Qiushi Wu, Can we call kobject_del() instead of kobject_put() when kobject_init_and_add() failed ? If it's unclear, I think we should fix this by calling kobject_put() when kobject_init_and_add() fails, and goto free_dev_subgroups. Regards, On Thu, May 28, 2020 at 5:10 AM wrote: > > From: Qiushi Wu > > kobject_init_and_add() takes reference even when it fails. > In nilfs_sysfs_create_device_group(), the memory allocated by > kobject_init_and_add() is not freed when kobject_init_and_add() > fails. Thus replace the jump target "free_dev_subgroups" by > "cleanup_dev_kobject". > > Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/ group") > Signed-off-by: Qiushi Wu > --- > fs/nilfs2/sysfs.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c > index e60be7bb55b0..4a74756d52fe 100644 > --- a/fs/nilfs2/sysfs.c > +++ b/fs/nilfs2/sysfs.c > @@ -1000,7 +1000,7 @@ int nilfs_sysfs_create_device_group(struct super_block > *sb) > err = kobject_init_and_add(>ns_dev_kobj, _dev_ktype, > NULL, > "%s", sb->s_id); > if (err) > - goto free_dev_subgroups; > + goto cleanup_dev_kobject; > > err = nilfs_sysfs_create_mounted_snapshots_group(nilfs); > if (err) > @@ -1038,8 +1038,6 @@ int nilfs_sysfs_create_device_group(struct super_block > *sb) > > cleanup_dev_kobject: > kobject_del(>ns_dev_kobj); > - > -free_dev_subgroups: > kfree(nilfs->ns_dev_subgroups); > > failed_create_device_group: > -- > 2.17.1 >
Re: [PATCH] nilfs2: Fix reference count leak in nilfs_sysfs_create_snapshot_group.
Andrew, Apply this, please. Acked-by: Ryusuke Konishi On Thu, May 28, 2020 at 4:55 AM wrote: > > From: Qiushi Wu > > kobject_init_and_add() takes reference even when it fails. > If this function returns an error, kobject_put() must be called to > properly clean up the memory associated with the object. Previous > commit "b8eb718348b8" fixed a similar problem. > > Fixes: a5a7332a291b ("nilfs2: add > /sys/fs/nilfs2//mounted_snapshots/group") > Signed-off-by: Qiushi Wu > --- > fs/nilfs2/sysfs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c > index e60be7bb55b0..b2517c5e773a 100644 > --- a/fs/nilfs2/sysfs.c > +++ b/fs/nilfs2/sysfs.c > @@ -209,8 +209,10 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root > *root) > "%llu", root->cno); > } > > - if (err) > + if (err) { > + kobject_put(>snapshot_kobj); > return err; > + } > > return 0; > } > -- > 2.17.1 >
[PATCH] MAINTAINERS: nilfs2: update email address
Change my email since lab.ntt.co.jp email domain has been deprecated due to company policy. Signed-off-by: Ryusuke Konishi --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 01a52fc..b8eadb3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6,7 +6,7 @@ F: include/uapi/linux/nfs* F: include/uapi/linux/sunrpc/ NILFS2 FILESYSTEM -M: Ryusuke Konishi +M: Ryusuke Konishi L: linux-ni...@vger.kernel.org W: https://nilfs.sourceforge.io/ W: https://nilfs.osdn.jp/ -- 1.8.3.1
Re: [PATCH] nilfs2: do not use unexported cpu_to_le32()/le32_to_cpu() in uapi header
Yamada-san, > To automate this testing, I will merge the following for 5.3-rc1: > https://patchwork.kernel.org/patch/11024715/ Thank you. I could get the series through linux-next tree, and could reproduce the build error by enabling the new coverage test for nilfs2_ondisk.h. Acked-by: Ryusuke Konishi Regards, Ryusuke Konishi 2019年7月7日(日) 15:42 Masahiro Yamada : > > Konishi-san, > > > On Sun, Jul 7, 2019 at 3:11 PM Ryusuke Konishi > wrote: > > > > Yamada-san, > > > > I'm sorry for not being able to follow. > > > > Could you tell me how did you find the build error? > > Still I cannot reproduce the error in my environment. > > > "You can compile UAPI headers in kernel-space" does not necessarily mean > "you can compile them in user-space". > > To make sure UAPI headers can be included from libc etc. > you must compile them after 'make headers_install', > but people often miss to test that. > > To automate this testing, I will merge the following for 5.3-rc1: > https://patchwork.kernel.org/patch/11024715/ > > Once it lands in upstream, all the new breakage > will be caught by 0-day bot. > > Currently, nilfs2_ondisk.h is excluded from the test coverage > since it is broken. > > Thanks. > Masahiro Yamada > > > > > Or, if it's right that we should not use > > cpu_to_le{16,32,64}/le{16,32,64}_to_cpu() in UAPI header files, > > I will acknowledge the change and modify nilfs utilities to comply > > with the guideline. > > > > Thanks, > > Ryusuke Konishi > > > > 2019年7月7日(日) 13:31 Masahiro Yamada : > > > > > > Hi Andrew, > > > > > > On Sun, Jul 7, 2019 at 12:38 PM Andrew Morton > > > wrote: > > > > > > > > > > > Seems fairly serious. I'm thinking this needs a cc:stable? > > > > > > > > > Ah, yes. > > > > > > > > > Cc: linux-stable # 4.9 > > > Fixes: e63e88bc53ba ("nilfs2: move ioctl interface and disk layout to > > > uapi separately") > > > > > > > > > Thanks. > > > > > > -- > > > Best Regards > > > Masahiro Yamada > > > > -- > Best Regards > Masahiro Yamada
Re: [PATCH] nilfs2: do not use unexported cpu_to_le32()/le32_to_cpu() in uapi header
Yamada-san, I'm sorry for not being able to follow. Could you tell me how did you find the build error? Still I cannot reproduce the error in my environment. Or, if it's right that we should not use cpu_to_le{16,32,64}/le{16,32,64}_to_cpu() in UAPI header files, I will acknowledge the change and modify nilfs utilities to comply with the guideline. Thanks, Ryusuke Konishi 2019年7月7日(日) 13:31 Masahiro Yamada : > > Hi Andrew, > > On Sun, Jul 7, 2019 at 12:38 PM Andrew Morton > wrote: > > > > > Seems fairly serious. I'm thinking this needs a cc:stable? > > > Ah, yes. > > > Cc: linux-stable # 4.9 > Fixes: e63e88bc53ba ("nilfs2: move ioctl interface and disk layout to > uapi separately") > > > Thanks. > > -- > Best Regards > Masahiro Yamada
Re: [PATCH] nilfs2: fix potential use after free
Hi, Pan Bian Thank you for feeding back this patch. I reviewed this and am thinking this must be sent to upstream. Did you see any kernel oops on this bug ? Regards, Ryusuke Konishi On Mon, 26 Nov 2018 11:08:29 +0800, Pan Bian wrote: > brelse(bh) is called to drop the reference count of bh when the call > to nilfs_dat_translate fails. If the reference count hits 0, bh may be > freed. However, bh->b_page is unlocked and put after that, which may > result in a use-after-free bug. This patch moves the release operation > after unlocking and putting the page. > > Signed-off-by: Pan Bian > --- > fs/nilfs2/gcinode.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c > index aa3c328..a24bb29 100644 > --- a/fs/nilfs2/gcinode.c > +++ b/fs/nilfs2/gcinode.c > @@ -73,10 +73,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, > sector_t blkoff, > struct the_nilfs *nilfs = inode->i_sb->s_fs_info; > > err = nilfs_dat_translate(nilfs->ns_dat, vbn, ); > - if (unlikely(err)) { /* -EIO, -ENOMEM, -ENOENT */ > - brelse(bh); > + if (unlikely(err)) /* -EIO, -ENOMEM, -ENOENT */ > goto failed; > - } > } > > lock_buffer(bh); > @@ -102,6 +100,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, > sector_t blkoff, > failed: > unlock_page(bh->b_page); > put_page(bh->b_page); > + if (unlikely(err)) > + brelse(bh); > return err; > } > > -- > 2.7.4 > >
Re: [PATCH] nilfs2: fix potential use after free
Hi, Pan Bian Thank you for feeding back this patch. I reviewed this and am thinking this must be sent to upstream. Did you see any kernel oops on this bug ? Regards, Ryusuke Konishi On Mon, 26 Nov 2018 11:08:29 +0800, Pan Bian wrote: > brelse(bh) is called to drop the reference count of bh when the call > to nilfs_dat_translate fails. If the reference count hits 0, bh may be > freed. However, bh->b_page is unlocked and put after that, which may > result in a use-after-free bug. This patch moves the release operation > after unlocking and putting the page. > > Signed-off-by: Pan Bian > --- > fs/nilfs2/gcinode.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c > index aa3c328..a24bb29 100644 > --- a/fs/nilfs2/gcinode.c > +++ b/fs/nilfs2/gcinode.c > @@ -73,10 +73,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, > sector_t blkoff, > struct the_nilfs *nilfs = inode->i_sb->s_fs_info; > > err = nilfs_dat_translate(nilfs->ns_dat, vbn, ); > - if (unlikely(err)) { /* -EIO, -ENOMEM, -ENOENT */ > - brelse(bh); > + if (unlikely(err)) /* -EIO, -ENOMEM, -ENOENT */ > goto failed; > - } > } > > lock_buffer(bh); > @@ -102,6 +100,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, > sector_t blkoff, > failed: > unlock_page(bh->b_page); > put_page(bh->b_page); > + if (unlikely(err)) > + brelse(bh); > return err; > } > > -- > 2.7.4 > >
Re: [PATCH v2] fs: Convert return type int to vm_fault_t
Hi Souptick, On Thu, 30 Aug 2018 16:33:52 -0700, Andrew Morton wrote: > On Thu, 30 Aug 2018 22:55:47 +0530 Souptick Joarder wrote: > >> Return type for fault handlers in ext4 and nilfs are >> changed to use vm_fault_t. >> >> Return type of block_page_mkwrite() is changed from >> int to vm_fault_t. The function signature of >> block_page_mkwrite() is changed to add one new parameter >> int *err. This will provide a way for caller functions >> to get error value along with return value and use it >> further. >> >> Return type of block_page_mkwrite_return() is also changed >> to use new vm_fault_t type. >> --- a/fs/nilfs2/file.c >> +++ b/fs/nilfs2/file.c >> @@ -51,13 +51,14 @@ int nilfs_sync_file(struct file *file, loff_t start, >> loff_t end, int datasync) >> return err; >> } >> >> -static int nilfs_page_mkwrite(struct vm_fault *vmf) >> +static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) > > nilfs_page_mkwrite() already has return type vm_fault_t in Linus's > kernel, due to the now-merged > fs-nilfs2-adding-new-return-type-vm_fault_t.patch. Looks like a simple > fix. In the first patch in this thread, this return type change was excluded correctly for nilfs_page_mkwrite() though the changelog was inaccurate in that sense. Please confirm your base point of the revised patch. Regards, Ryusuke Konishi > > I'm beginning to feel vm_fault_t exhaustion. Please remind me what > benefit we're going to get out of all this churn? > >> >> ... >>
Re: [PATCH v2] fs: Convert return type int to vm_fault_t
Hi Souptick, On Thu, 30 Aug 2018 16:33:52 -0700, Andrew Morton wrote: > On Thu, 30 Aug 2018 22:55:47 +0530 Souptick Joarder wrote: > >> Return type for fault handlers in ext4 and nilfs are >> changed to use vm_fault_t. >> >> Return type of block_page_mkwrite() is changed from >> int to vm_fault_t. The function signature of >> block_page_mkwrite() is changed to add one new parameter >> int *err. This will provide a way for caller functions >> to get error value along with return value and use it >> further. >> >> Return type of block_page_mkwrite_return() is also changed >> to use new vm_fault_t type. >> --- a/fs/nilfs2/file.c >> +++ b/fs/nilfs2/file.c >> @@ -51,13 +51,14 @@ int nilfs_sync_file(struct file *file, loff_t start, >> loff_t end, int datasync) >> return err; >> } >> >> -static int nilfs_page_mkwrite(struct vm_fault *vmf) >> +static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) > > nilfs_page_mkwrite() already has return type vm_fault_t in Linus's > kernel, due to the now-merged > fs-nilfs2-adding-new-return-type-vm_fault_t.patch. Looks like a simple > fix. In the first patch in this thread, this return type change was excluded correctly for nilfs_page_mkwrite() though the changelog was inaccurate in that sense. Please confirm your base point of the revised patch. Regards, Ryusuke Konishi > > I'm beginning to feel vm_fault_t exhaustion. Please remind me what > benefit we're going to get out of all this churn? > >> >> ... >>
[PATCH] nilfs2: convert to SPDX license tags
Remove the verbose license text from NILFS2 files and replace them with SPDX tags. This does not change the license of any of the code. Signed-off-by: Ryusuke Konishi --- fs/nilfs2/alloc.c | 11 +-- fs/nilfs2/alloc.h | 11 +-- fs/nilfs2/bmap.c | 11 +-- fs/nilfs2/bmap.h | 11 +-- fs/nilfs2/btnode.c| 11 +-- fs/nilfs2/btnode.h| 11 +-- fs/nilfs2/btree.c | 11 +-- fs/nilfs2/btree.h | 11 +-- fs/nilfs2/cpfile.c| 11 +-- fs/nilfs2/cpfile.h| 11 +-- fs/nilfs2/dat.c | 11 +-- fs/nilfs2/dat.h | 11 +-- fs/nilfs2/dir.c | 11 +-- fs/nilfs2/direct.c| 11 +-- fs/nilfs2/direct.h| 11 +-- fs/nilfs2/file.c | 11 +-- fs/nilfs2/gcinode.c | 11 +-- fs/nilfs2/ifile.c | 11 +-- fs/nilfs2/ifile.h | 11 +-- fs/nilfs2/inode.c | 11 +-- fs/nilfs2/ioctl.c | 11 +-- fs/nilfs2/mdt.c | 11 +-- fs/nilfs2/mdt.h | 11 +-- fs/nilfs2/namei.c | 11 +-- fs/nilfs2/nilfs.h | 11 +-- fs/nilfs2/page.c | 11 +-- fs/nilfs2/page.h | 11 +-- fs/nilfs2/recovery.c | 11 +-- fs/nilfs2/segbuf.c| 11 +-- fs/nilfs2/segbuf.h| 11 +-- fs/nilfs2/segment.c | 11 +-- fs/nilfs2/segment.h | 11 +-- fs/nilfs2/sufile.c| 11 +-- fs/nilfs2/sufile.h| 11 +-- fs/nilfs2/super.c | 11 +-- fs/nilfs2/sysfs.c | 11 +-- fs/nilfs2/sysfs.h | 11 +-- fs/nilfs2/the_nilfs.c | 11 +-- fs/nilfs2/the_nilfs.h | 11 +-- 39 files changed, 39 insertions(+), 390 deletions(-) diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c index 03b8ba9..235b959 100644 --- a/fs/nilfs2/alloc.c +++ b/fs/nilfs2/alloc.c @@ -1,18 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * alloc.c - NILFS dat/inode allocator * * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * * Originally written by Koji Sato. * Two allocators were unified by Ryusuke Konishi and Amagai Yoshiji. */ diff --git a/fs/nilfs2/alloc.h b/fs/nilfs2/alloc.h index 05149e6..0303c39 100644 --- a/fs/nilfs2/alloc.h +++ b/fs/nilfs2/alloc.h @@ -1,18 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * alloc.h - persistent object (dat entry/disk inode) allocator/deallocator * * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * * Originally written by Koji Sato. * Two allocators were unified by Ryusuke Konishi and Amagai Yoshiji. */ diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 01fb183..fb5a9a8 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -1,18 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * bmap.c - NILFS block mapping. * * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * * Written by Koji Sato. */ diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h index 2b6ffbe..2c63858e 100644 --- a/fs/nilfs2/bmap.h +++ b/fs/nilfs2/bmap.h @@ -1,18 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * bmap.h - NILFS block mapping. * * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published
[PATCH] nilfs2: convert to SPDX license tags
Remove the verbose license text from NILFS2 files and replace them with SPDX tags. This does not change the license of any of the code. Signed-off-by: Ryusuke Konishi --- fs/nilfs2/alloc.c | 11 +-- fs/nilfs2/alloc.h | 11 +-- fs/nilfs2/bmap.c | 11 +-- fs/nilfs2/bmap.h | 11 +-- fs/nilfs2/btnode.c| 11 +-- fs/nilfs2/btnode.h| 11 +-- fs/nilfs2/btree.c | 11 +-- fs/nilfs2/btree.h | 11 +-- fs/nilfs2/cpfile.c| 11 +-- fs/nilfs2/cpfile.h| 11 +-- fs/nilfs2/dat.c | 11 +-- fs/nilfs2/dat.h | 11 +-- fs/nilfs2/dir.c | 11 +-- fs/nilfs2/direct.c| 11 +-- fs/nilfs2/direct.h| 11 +-- fs/nilfs2/file.c | 11 +-- fs/nilfs2/gcinode.c | 11 +-- fs/nilfs2/ifile.c | 11 +-- fs/nilfs2/ifile.h | 11 +-- fs/nilfs2/inode.c | 11 +-- fs/nilfs2/ioctl.c | 11 +-- fs/nilfs2/mdt.c | 11 +-- fs/nilfs2/mdt.h | 11 +-- fs/nilfs2/namei.c | 11 +-- fs/nilfs2/nilfs.h | 11 +-- fs/nilfs2/page.c | 11 +-- fs/nilfs2/page.h | 11 +-- fs/nilfs2/recovery.c | 11 +-- fs/nilfs2/segbuf.c| 11 +-- fs/nilfs2/segbuf.h| 11 +-- fs/nilfs2/segment.c | 11 +-- fs/nilfs2/segment.h | 11 +-- fs/nilfs2/sufile.c| 11 +-- fs/nilfs2/sufile.h| 11 +-- fs/nilfs2/super.c | 11 +-- fs/nilfs2/sysfs.c | 11 +-- fs/nilfs2/sysfs.h | 11 +-- fs/nilfs2/the_nilfs.c | 11 +-- fs/nilfs2/the_nilfs.h | 11 +-- 39 files changed, 39 insertions(+), 390 deletions(-) diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c index 03b8ba9..235b959 100644 --- a/fs/nilfs2/alloc.c +++ b/fs/nilfs2/alloc.c @@ -1,18 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * alloc.c - NILFS dat/inode allocator * * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * * Originally written by Koji Sato. * Two allocators were unified by Ryusuke Konishi and Amagai Yoshiji. */ diff --git a/fs/nilfs2/alloc.h b/fs/nilfs2/alloc.h index 05149e6..0303c39 100644 --- a/fs/nilfs2/alloc.h +++ b/fs/nilfs2/alloc.h @@ -1,18 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * alloc.h - persistent object (dat entry/disk inode) allocator/deallocator * * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * * Originally written by Koji Sato. * Two allocators were unified by Ryusuke Konishi and Amagai Yoshiji. */ diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 01fb183..fb5a9a8 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -1,18 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * bmap.c - NILFS block mapping. * * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * * Written by Koji Sato. */ diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h index 2b6ffbe..2c63858e 100644 --- a/fs/nilfs2/bmap.h +++ b/fs/nilfs2/bmap.h @@ -1,18 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * bmap.h - NILFS block mapping. * * Copyright (C) 2006-2008 Nippon Telegraph and Telephone Corporation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published
Re: [PATCH] fs: Convert return type int to vm_fault_t
vma->vm_file); > > down_read(_I(inode)->i_mmap_sem); > > - ret = ext4_convert_inline_data(inode); > - if (ret) > + err = ext4_convert_inline_data(inode); > + if (err) > goto out_ret; > > + err = 0; > /* Delalloc case is easy... */ > if (test_opt(inode->i_sb, DELALLOC) && > !ext4_should_journal_data(inode) && > !ext4_nonda_switch(inode->i_sb)) { > do { > ret = block_page_mkwrite(vma, vmf, > -ext4_da_get_block_prep); > - } while (ret == -ENOSPC && > + ext4_da_get_block_prep, ); > + } while (err == -ENOSPC && > ext4_should_retry_alloc(inode->i_sb, )); > - goto out_ret; > + goto out; > } > > lock_page(page); > @@ -6226,36 +6227,37 @@ int ext4_page_mkwrite(struct vm_fault *vmf) > ret = VM_FAULT_SIGBUS; > goto out; > } > - ret = block_page_mkwrite(vma, vmf, get_block); > + err = 0; > + ret = block_page_mkwrite(vma, vmf, get_block, ); > if (!ret && ext4_should_journal_data(inode)) { > if (ext4_walk_page_buffers(handle, page_buffers(page), 0, > PAGE_SIZE, NULL, do_journal_get_write_access)) { > unlock_page(page); > - ret = VM_FAULT_SIGBUS; > ext4_journal_stop(handle); > goto out; > } > ext4_set_inode_state(inode, EXT4_STATE_JDATA); > } > ext4_journal_stop(handle); > - if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, )) > + if (err == -ENOSPC && > + ext4_should_retry_alloc(inode->i_sb, )) > goto retry_alloc; > out_ret: > - ret = block_page_mkwrite_return(ret); > + ret = block_page_mkwrite_return(err); > out: > up_read(_I(inode)->i_mmap_sem); > sb_end_pagefault(inode->i_sb); > return ret; > } > > -int ext4_filemap_fault(struct vm_fault *vmf) > +vm_fault_t ext4_filemap_fault(struct vm_fault *vmf) > { > struct inode *inode = file_inode(vmf->vma->vm_file); > - int err; > + vm_fault_t ret; > > down_read(_I(inode)->i_mmap_sem); > - err = filemap_fault(vmf); > + ret = filemap_fault(vmf); > up_read(_I(inode)->i_mmap_sem); > > - return err; > + return ret; > } > diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c > index 7da0fac..58d2a81 100644 > --- a/fs/nilfs2/file.c > +++ b/fs/nilfs2/file.c > @@ -57,7 +57,8 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) > struct page *page = vmf->page; > struct inode *inode = file_inode(vma->vm_file); > struct nilfs_transaction_info ti; > - int ret = 0; > + vm_fault_t ret = VM_FAULT_LOCKED; > + int err = 0; > > if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info))) > return VM_FAULT_SIGBUS; /* -ENOSPC */ > @@ -67,7 +68,7 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) > if (page->mapping != inode->i_mapping || > page_offset(page) >= i_size_read(inode) || !PageUptodate(page)) { > unlock_page(page); > - ret = -EFAULT; /* make the VM retry the fault */ > + ret = VM_FAULT_NOPAGE; /* make the VM retry the fault */ > goto out; > } > > @@ -99,13 +100,16 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault > *vmf) > /* >* fill hole blocks >*/ > - ret = nilfs_transaction_begin(inode->i_sb, , 1); > + err = nilfs_transaction_begin(inode->i_sb, , 1); > /* never returns -ENOMEM, but may return -ENOSPC */ > - if (unlikely(ret)) > + if (unlikely(err)) { > + ret = block_page_mkwrite_return(err); > goto out; > + } > > + err = 0; This initialization looks unnecessary. "err" is always zero here. Regards, Ryusuke Konishi > file_update_time(vma->vm_file); > - ret = block_page_mkwrite(vma, vmf, nilfs_get_block); > + ret = block_page_mkwrite(vma, vmf, nilfs_get_block, ); > if (ret) { > nilfs_transaction_abort(inode->i_sb); > goto out; > @@ -117,7 +121,7 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) > wait_for_stable_page(page); > out: > sb_end_pagefault(inode->i_sb); > - return
Re: [PATCH] fs: Convert return type int to vm_fault_t
vma->vm_file); > > down_read(_I(inode)->i_mmap_sem); > > - ret = ext4_convert_inline_data(inode); > - if (ret) > + err = ext4_convert_inline_data(inode); > + if (err) > goto out_ret; > > + err = 0; > /* Delalloc case is easy... */ > if (test_opt(inode->i_sb, DELALLOC) && > !ext4_should_journal_data(inode) && > !ext4_nonda_switch(inode->i_sb)) { > do { > ret = block_page_mkwrite(vma, vmf, > -ext4_da_get_block_prep); > - } while (ret == -ENOSPC && > + ext4_da_get_block_prep, ); > + } while (err == -ENOSPC && > ext4_should_retry_alloc(inode->i_sb, )); > - goto out_ret; > + goto out; > } > > lock_page(page); > @@ -6226,36 +6227,37 @@ int ext4_page_mkwrite(struct vm_fault *vmf) > ret = VM_FAULT_SIGBUS; > goto out; > } > - ret = block_page_mkwrite(vma, vmf, get_block); > + err = 0; > + ret = block_page_mkwrite(vma, vmf, get_block, ); > if (!ret && ext4_should_journal_data(inode)) { > if (ext4_walk_page_buffers(handle, page_buffers(page), 0, > PAGE_SIZE, NULL, do_journal_get_write_access)) { > unlock_page(page); > - ret = VM_FAULT_SIGBUS; > ext4_journal_stop(handle); > goto out; > } > ext4_set_inode_state(inode, EXT4_STATE_JDATA); > } > ext4_journal_stop(handle); > - if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, )) > + if (err == -ENOSPC && > + ext4_should_retry_alloc(inode->i_sb, )) > goto retry_alloc; > out_ret: > - ret = block_page_mkwrite_return(ret); > + ret = block_page_mkwrite_return(err); > out: > up_read(_I(inode)->i_mmap_sem); > sb_end_pagefault(inode->i_sb); > return ret; > } > > -int ext4_filemap_fault(struct vm_fault *vmf) > +vm_fault_t ext4_filemap_fault(struct vm_fault *vmf) > { > struct inode *inode = file_inode(vmf->vma->vm_file); > - int err; > + vm_fault_t ret; > > down_read(_I(inode)->i_mmap_sem); > - err = filemap_fault(vmf); > + ret = filemap_fault(vmf); > up_read(_I(inode)->i_mmap_sem); > > - return err; > + return ret; > } > diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c > index 7da0fac..58d2a81 100644 > --- a/fs/nilfs2/file.c > +++ b/fs/nilfs2/file.c > @@ -57,7 +57,8 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) > struct page *page = vmf->page; > struct inode *inode = file_inode(vma->vm_file); > struct nilfs_transaction_info ti; > - int ret = 0; > + vm_fault_t ret = VM_FAULT_LOCKED; > + int err = 0; > > if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info))) > return VM_FAULT_SIGBUS; /* -ENOSPC */ > @@ -67,7 +68,7 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) > if (page->mapping != inode->i_mapping || > page_offset(page) >= i_size_read(inode) || !PageUptodate(page)) { > unlock_page(page); > - ret = -EFAULT; /* make the VM retry the fault */ > + ret = VM_FAULT_NOPAGE; /* make the VM retry the fault */ > goto out; > } > > @@ -99,13 +100,16 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault > *vmf) > /* >* fill hole blocks >*/ > - ret = nilfs_transaction_begin(inode->i_sb, , 1); > + err = nilfs_transaction_begin(inode->i_sb, , 1); > /* never returns -ENOMEM, but may return -ENOSPC */ > - if (unlikely(ret)) > + if (unlikely(err)) { > + ret = block_page_mkwrite_return(err); > goto out; > + } > > + err = 0; This initialization looks unnecessary. "err" is always zero here. Regards, Ryusuke Konishi > file_update_time(vma->vm_file); > - ret = block_page_mkwrite(vma, vmf, nilfs_get_block); > + ret = block_page_mkwrite(vma, vmf, nilfs_get_block, ); > if (ret) { > nilfs_transaction_abort(inode->i_sb); > goto out; > @@ -117,7 +121,7 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) > wait_for_stable_page(page); > out: > sb_end_pagefault(inode->i_sb); > - return
[PATCH] fs: nilfs2: Adding new return type vm_fault_t
From: Souptick Joarder Use new return type vm_fault_t for page_mkwrite handler. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Signed-off-by: Ryusuke Konishi --- fs/nilfs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index c5fa3de..7da0fac 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -51,7 +51,7 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) return err; } -static int nilfs_page_mkwrite(struct vm_fault *vmf) +static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct page *page = vmf->page; -- 1.8.3.1
[PATCH] fs: nilfs2: Adding new return type vm_fault_t
From: Souptick Joarder Use new return type vm_fault_t for page_mkwrite handler. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox Signed-off-by: Ryusuke Konishi --- fs/nilfs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index c5fa3de..7da0fac 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -51,7 +51,7 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) return err; } -static int nilfs_page_mkwrite(struct vm_fault *vmf) +static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct page *page = vmf->page; -- 1.8.3.1
Re: [PATCH] nilfs2: use time64_t internally
2018-01-23 6:10 GMT+09:00 Arnd Bergmann <a...@arndb.de>: > The superblock and segment timestamps are used only internally in nilfs2 > and can be read out using sysfs. Since we are using the old 'get_seconds()' > interface and store the data as timestamps, the behavior differs slightly > between 64-bit and 32-bit kernels, the latter will show incorrect timestamps > after 2038 in sysfs, and presumably fail completely in 2106 as comparisons > go wrong. > > This changes nilfs2 to use time64_t with ktime_get_real_seconds() to handle > timestamps, making the behavior consistent and correct on both 32-bit > and 64-bit machines. > > The on-disk format already uses 64-bit timestamps, so nothing changes > there. > > Signed-off-by: Arnd Bergmann <a...@arndb.de> Thank you for this patch. Acked-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> > --- > fs/nilfs2/segbuf.c| 2 +- > fs/nilfs2/segbuf.h| 4 ++-- > fs/nilfs2/segment.c | 2 +- > fs/nilfs2/segment.h | 2 +- > fs/nilfs2/sufile.c| 2 +- > fs/nilfs2/sufile.h| 2 +- > fs/nilfs2/super.c | 4 ++-- > fs/nilfs2/sysfs.c | 21 ++--- > fs/nilfs2/the_nilfs.h | 8 > 9 files changed, 23 insertions(+), 24 deletions(-) > > diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c > index 6c5009cc4e6f..68cb9e4740b4 100644 > --- a/fs/nilfs2/segbuf.c > +++ b/fs/nilfs2/segbuf.c > @@ -130,7 +130,7 @@ int nilfs_segbuf_extend_payload(struct > nilfs_segment_buffer *segbuf, > } > > int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned int > flags, > - time_t ctime, __u64 cno) > + time64_t ctime, __u64 cno) > { > int err; > > diff --git a/fs/nilfs2/segbuf.h b/fs/nilfs2/segbuf.h > index 7bbccc099709..10e16935fff6 100644 > --- a/fs/nilfs2/segbuf.h > +++ b/fs/nilfs2/segbuf.h > @@ -46,7 +46,7 @@ struct nilfs_segsum_info { > unsigned long nfileblk; > u64 seg_seq; > __u64 cno; > - time_t ctime; > + time64_tctime; > sector_tnext; > }; > > @@ -120,7 +120,7 @@ void nilfs_segbuf_map_cont(struct nilfs_segment_buffer > *segbuf, >struct nilfs_segment_buffer *prev); > void nilfs_segbuf_set_next_segnum(struct nilfs_segment_buffer *, __u64, > struct the_nilfs *); > -int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned int, time_t, > +int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned int, time64_t, >__u64); > int nilfs_segbuf_extend_segsum(struct nilfs_segment_buffer *); > int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *, > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index 9f3ffba41533..0953635e7d48 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -2040,7 +2040,7 @@ static int nilfs_segctor_do_construct(struct > nilfs_sc_info *sci, int mode) > goto out; > > /* Update time stamp */ > - sci->sc_seg_ctime = get_seconds(); > + sci->sc_seg_ctime = ktime_get_real_seconds(); > > err = nilfs_segctor_collect(sci, nilfs, mode); > if (unlikely(err)) > diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h > index 84084a4d9b3e..04634e3e3d58 100644 > --- a/fs/nilfs2/segment.h > +++ b/fs/nilfs2/segment.h > @@ -157,7 +157,7 @@ struct nilfs_sc_info { > unsigned long sc_blk_cnt; > unsigned long sc_datablk_cnt; > unsigned long sc_nblk_this_inc; > - time_t sc_seg_ctime; > + time64_tsc_seg_ctime; > __u64 sc_cno; > unsigned long sc_flags; > > diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c > index 1341a41e7b43..c7fa139d50e8 100644 > --- a/fs/nilfs2/sufile.c > +++ b/fs/nilfs2/sufile.c > @@ -526,7 +526,7 @@ int nilfs_sufile_mark_dirty(struct inode *sufile, __u64 > segnum) > * @modtime: modification time (option) > */ > int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum, > - unsigned long nblocks, time_t modtime) > + unsigned long nblocks, time64_t modtime) > { > struct buffer_head *bh; > struct nilfs_segment_usage *su; > diff --git a/fs/nilfs2/sufile.h b/fs/nilfs2/sufile.h > index 158a9190c8ec..673a891350f4 100644 > --- a/fs/nilfs2/sufile.h > +++ b/fs/nilfs2/sufile.h > @@ -35,7 +35
Re: [PATCH] nilfs2: use time64_t internally
2018-01-23 6:10 GMT+09:00 Arnd Bergmann : > The superblock and segment timestamps are used only internally in nilfs2 > and can be read out using sysfs. Since we are using the old 'get_seconds()' > interface and store the data as timestamps, the behavior differs slightly > between 64-bit and 32-bit kernels, the latter will show incorrect timestamps > after 2038 in sysfs, and presumably fail completely in 2106 as comparisons > go wrong. > > This changes nilfs2 to use time64_t with ktime_get_real_seconds() to handle > timestamps, making the behavior consistent and correct on both 32-bit > and 64-bit machines. > > The on-disk format already uses 64-bit timestamps, so nothing changes > there. > > Signed-off-by: Arnd Bergmann Thank you for this patch. Acked-by: Ryusuke Konishi > --- > fs/nilfs2/segbuf.c| 2 +- > fs/nilfs2/segbuf.h| 4 ++-- > fs/nilfs2/segment.c | 2 +- > fs/nilfs2/segment.h | 2 +- > fs/nilfs2/sufile.c| 2 +- > fs/nilfs2/sufile.h| 2 +- > fs/nilfs2/super.c | 4 ++-- > fs/nilfs2/sysfs.c | 21 ++--- > fs/nilfs2/the_nilfs.h | 8 > 9 files changed, 23 insertions(+), 24 deletions(-) > > diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c > index 6c5009cc4e6f..68cb9e4740b4 100644 > --- a/fs/nilfs2/segbuf.c > +++ b/fs/nilfs2/segbuf.c > @@ -130,7 +130,7 @@ int nilfs_segbuf_extend_payload(struct > nilfs_segment_buffer *segbuf, > } > > int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned int > flags, > - time_t ctime, __u64 cno) > + time64_t ctime, __u64 cno) > { > int err; > > diff --git a/fs/nilfs2/segbuf.h b/fs/nilfs2/segbuf.h > index 7bbccc099709..10e16935fff6 100644 > --- a/fs/nilfs2/segbuf.h > +++ b/fs/nilfs2/segbuf.h > @@ -46,7 +46,7 @@ struct nilfs_segsum_info { > unsigned long nfileblk; > u64 seg_seq; > __u64 cno; > - time_t ctime; > + time64_tctime; > sector_tnext; > }; > > @@ -120,7 +120,7 @@ void nilfs_segbuf_map_cont(struct nilfs_segment_buffer > *segbuf, >struct nilfs_segment_buffer *prev); > void nilfs_segbuf_set_next_segnum(struct nilfs_segment_buffer *, __u64, > struct the_nilfs *); > -int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned int, time_t, > +int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned int, time64_t, >__u64); > int nilfs_segbuf_extend_segsum(struct nilfs_segment_buffer *); > int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *, > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index 9f3ffba41533..0953635e7d48 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -2040,7 +2040,7 @@ static int nilfs_segctor_do_construct(struct > nilfs_sc_info *sci, int mode) > goto out; > > /* Update time stamp */ > - sci->sc_seg_ctime = get_seconds(); > + sci->sc_seg_ctime = ktime_get_real_seconds(); > > err = nilfs_segctor_collect(sci, nilfs, mode); > if (unlikely(err)) > diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h > index 84084a4d9b3e..04634e3e3d58 100644 > --- a/fs/nilfs2/segment.h > +++ b/fs/nilfs2/segment.h > @@ -157,7 +157,7 @@ struct nilfs_sc_info { > unsigned long sc_blk_cnt; > unsigned long sc_datablk_cnt; > unsigned long sc_nblk_this_inc; > - time_t sc_seg_ctime; > + time64_tsc_seg_ctime; > __u64 sc_cno; > unsigned long sc_flags; > > diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c > index 1341a41e7b43..c7fa139d50e8 100644 > --- a/fs/nilfs2/sufile.c > +++ b/fs/nilfs2/sufile.c > @@ -526,7 +526,7 @@ int nilfs_sufile_mark_dirty(struct inode *sufile, __u64 > segnum) > * @modtime: modification time (option) > */ > int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum, > - unsigned long nblocks, time_t modtime) > + unsigned long nblocks, time64_t modtime) > { > struct buffer_head *bh; > struct nilfs_segment_usage *su; > diff --git a/fs/nilfs2/sufile.h b/fs/nilfs2/sufile.h > index 158a9190c8ec..673a891350f4 100644 > --- a/fs/nilfs2/sufile.h > +++ b/fs/nilfs2/sufile.h > @@ -35,7 +35,7 @@ int nilfs_sufile_set_alloc_range(struct inode *sufile, > __u64 start, __u64 end); >
[PATCH] MAINTAINERS, nilfs2: change project home URLs
The domain of NILFS project home was changed to "nilfs.sourceforge.io" to enable https access (the previous domain "nilfs.sourceforge.net" is redirected to the new one). Modify URLs of the project home to reflect this change and to replace their protocol from http to https. Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- Documentation/filesystems/nilfs2.txt | 4 ++-- MAINTAINERS | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/filesystems/nilfs2.txt b/Documentation/filesystems/nilfs2.txt index c0727dc..f2f3f85 100644 --- a/Documentation/filesystems/nilfs2.txt +++ b/Documentation/filesystems/nilfs2.txt @@ -25,8 +25,8 @@ available from the following download page. At least "mkfs.nilfs2", cleaner or garbage collector) are required. Details on the tools are described in the man pages included in the package. -Project web page:http://nilfs.sourceforge.net/ -Download page: http://nilfs.sourceforge.net/en/download.html +Project web page:https://nilfs.sourceforge.io/ +Download page: https://nilfs.sourceforge.io/en/download.html List info: http://vger.kernel.org/vger-lists.html#linux-nilfs Caveats diff --git a/MAINTAINERS b/MAINTAINERS index 95c3fa1..9741ce5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9638,8 +9638,8 @@ F:include/uapi/linux/sunrpc/ NILFS2 FILESYSTEM M: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> L: linux-ni...@vger.kernel.org -W: http://nilfs.sourceforge.net/ -W: http://nilfs.osdn.jp/ +W: https://nilfs.sourceforge.io/ +W: https://nilfs.osdn.jp/ T: git git://github.com/konis/nilfs2.git S: Supported F: Documentation/filesystems/nilfs2.txt -- 1.8.3.1
[PATCH] MAINTAINERS, nilfs2: change project home URLs
The domain of NILFS project home was changed to "nilfs.sourceforge.io" to enable https access (the previous domain "nilfs.sourceforge.net" is redirected to the new one). Modify URLs of the project home to reflect this change and to replace their protocol from http to https. Signed-off-by: Ryusuke Konishi --- Documentation/filesystems/nilfs2.txt | 4 ++-- MAINTAINERS | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/filesystems/nilfs2.txt b/Documentation/filesystems/nilfs2.txt index c0727dc..f2f3f85 100644 --- a/Documentation/filesystems/nilfs2.txt +++ b/Documentation/filesystems/nilfs2.txt @@ -25,8 +25,8 @@ available from the following download page. At least "mkfs.nilfs2", cleaner or garbage collector) are required. Details on the tools are described in the man pages included in the package. -Project web page:http://nilfs.sourceforge.net/ -Download page: http://nilfs.sourceforge.net/en/download.html +Project web page:https://nilfs.sourceforge.io/ +Download page: https://nilfs.sourceforge.io/en/download.html List info: http://vger.kernel.org/vger-lists.html#linux-nilfs Caveats diff --git a/MAINTAINERS b/MAINTAINERS index 95c3fa1..9741ce5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9638,8 +9638,8 @@ F:include/uapi/linux/sunrpc/ NILFS2 FILESYSTEM M: Ryusuke Konishi L: linux-ni...@vger.kernel.org -W: http://nilfs.sourceforge.net/ -W: http://nilfs.osdn.jp/ +W: https://nilfs.sourceforge.io/ +W: https://nilfs.osdn.jp/ T: git git://github.com/konis/nilfs2.git S: Supported F: Documentation/filesystems/nilfs2.txt -- 1.8.3.1
[PATCH 1/1] nilfs2: remove inode->i_version initialization
From: Jeff Layton <jlay...@redhat.com> It's never used in nilfs2. Signed-off-by: Jeff Layton <jlay...@redhat.com> Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/super.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 4fc018d..3ce20cd 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -160,7 +160,6 @@ struct inode *nilfs_alloc_inode(struct super_block *sb) ii->i_bh = NULL; ii->i_state = 0; ii->i_cno = 0; - ii->vfs_inode.i_version = 1; nilfs_mapping_init(>i_btnode_cache, >vfs_inode); return >vfs_inode; } -- 1.8.3.1
[PATCH 1/1] nilfs2: remove inode->i_version initialization
From: Jeff Layton It's never used in nilfs2. Signed-off-by: Jeff Layton Signed-off-by: Ryusuke Konishi --- fs/nilfs2/super.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 4fc018d..3ce20cd 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -160,7 +160,6 @@ struct inode *nilfs_alloc_inode(struct super_block *sb) ii->i_bh = NULL; ii->i_state = 0; ii->i_cno = 0; - ii->vfs_inode.i_version = 1; nilfs_mapping_init(>i_btnode_cache, >vfs_inode); return >vfs_inode; } -- 1.8.3.1
[PATCH 0/1] nilfs2 additional change
Hi Andrew, Please add the following change to the queue of next merge window: Jeff Layton (1): nilfs2: remove inode->i_version initialization Thanks, Ryusuke Konishi -- fs/nilfs2/super.c | 1 - 1 file changed, 1 deletion(-)
[PATCH 0/1] nilfs2 additional change
Hi Andrew, Please add the following change to the queue of next merge window: Jeff Layton (1): nilfs2: remove inode->i_version initialization Thanks, Ryusuke Konishi -- fs/nilfs2/super.c | 1 - 1 file changed, 1 deletion(-)
Re: [PATCH] fs/nilfs2: Convert timers to use timer_setup()
2017-10-17 8:59 GMT+09:00 Kees Cook <keesc...@chromium.org>: > In preparation for unconditionally passing the struct timer_list pointer to > all timer callbacks, switch to using the new timer_setup() and from_timer() > to pass the timer pointer explicitly. This requires adding a pointer to > hold the timer's target task, as the lifetime of sc_task doesn't appear to > match the timer's task. > > Cc: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> > Cc: linux-ni...@vger.kernel.org > Signed-off-by: Kees Cook <keesc...@chromium.org> Looks good. Acked-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> Thanks, Ryusuke Konishi > --- > fs/nilfs2/segment.c | 11 +-- > fs/nilfs2/segment.h | 1 + > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index 70ded52dc1dd..07b6154a081e 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -2404,11 +2404,11 @@ static int nilfs_segctor_construct(struct > nilfs_sc_info *sci, int mode) > return err; > } > > -static void nilfs_construction_timeout(unsigned long data) > +static void nilfs_construction_timeout(struct timer_list *t) > { > - struct task_struct *p = (struct task_struct *)data; > + struct nilfs_sc_info *sci = from_timer(sci, t, sc_timer); > > - wake_up_process(p); > + wake_up_process(sci->sc_timer_task); > } > > static void > @@ -2546,8 +2546,7 @@ static int nilfs_segctor_thread(void *arg) > struct the_nilfs *nilfs = sci->sc_super->s_fs_info; > int timeout = 0; > > - sci->sc_timer.data = (unsigned long)current; > - sci->sc_timer.function = nilfs_construction_timeout; > + sci->sc_timer_task = current; > > /* start sync. */ > sci->sc_task = current; > @@ -2678,7 +2677,7 @@ static struct nilfs_sc_info *nilfs_segctor_new(struct > super_block *sb, > INIT_LIST_HEAD(>sc_gc_inodes); > INIT_LIST_HEAD(>sc_iput_queue); > INIT_WORK(>sc_iput_work, nilfs_iput_work_func); > - init_timer(>sc_timer); > + timer_setup(>sc_timer, nilfs_construction_timeout, 0); > > sci->sc_interval = HZ * NILFS_SC_DEFAULT_TIMEOUT; > sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; > diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h > index 1060949d7dd2..84084a4d9b3e 100644 > --- a/fs/nilfs2/segment.h > +++ b/fs/nilfs2/segment.h > @@ -180,6 +180,7 @@ struct nilfs_sc_info { > unsigned long sc_watermark; > > struct timer_list sc_timer; > + struct task_struct *sc_timer_task; > struct task_struct *sc_task; > }; > > -- > 2.7.4 > > > -- > Kees Cook > Pixel Security
Re: [PATCH] fs/nilfs2: Convert timers to use timer_setup()
2017-10-17 8:59 GMT+09:00 Kees Cook : > In preparation for unconditionally passing the struct timer_list pointer to > all timer callbacks, switch to using the new timer_setup() and from_timer() > to pass the timer pointer explicitly. This requires adding a pointer to > hold the timer's target task, as the lifetime of sc_task doesn't appear to > match the timer's task. > > Cc: Ryusuke Konishi > Cc: linux-ni...@vger.kernel.org > Signed-off-by: Kees Cook Looks good. Acked-by: Ryusuke Konishi Thanks, Ryusuke Konishi > --- > fs/nilfs2/segment.c | 11 +-- > fs/nilfs2/segment.h | 1 + > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index 70ded52dc1dd..07b6154a081e 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -2404,11 +2404,11 @@ static int nilfs_segctor_construct(struct > nilfs_sc_info *sci, int mode) > return err; > } > > -static void nilfs_construction_timeout(unsigned long data) > +static void nilfs_construction_timeout(struct timer_list *t) > { > - struct task_struct *p = (struct task_struct *)data; > + struct nilfs_sc_info *sci = from_timer(sci, t, sc_timer); > > - wake_up_process(p); > + wake_up_process(sci->sc_timer_task); > } > > static void > @@ -2546,8 +2546,7 @@ static int nilfs_segctor_thread(void *arg) > struct the_nilfs *nilfs = sci->sc_super->s_fs_info; > int timeout = 0; > > - sci->sc_timer.data = (unsigned long)current; > - sci->sc_timer.function = nilfs_construction_timeout; > + sci->sc_timer_task = current; > > /* start sync. */ > sci->sc_task = current; > @@ -2678,7 +2677,7 @@ static struct nilfs_sc_info *nilfs_segctor_new(struct > super_block *sb, > INIT_LIST_HEAD(>sc_gc_inodes); > INIT_LIST_HEAD(>sc_iput_queue); > INIT_WORK(>sc_iput_work, nilfs_iput_work_func); > - init_timer(>sc_timer); > + timer_setup(>sc_timer, nilfs_construction_timeout, 0); > > sci->sc_interval = HZ * NILFS_SC_DEFAULT_TIMEOUT; > sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; > diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h > index 1060949d7dd2..84084a4d9b3e 100644 > --- a/fs/nilfs2/segment.h > +++ b/fs/nilfs2/segment.h > @@ -180,6 +180,7 @@ struct nilfs_sc_info { > unsigned long sc_watermark; > > struct timer_list sc_timer; > + struct task_struct *sc_timer_task; > struct task_struct *sc_task; > }; > > -- > 2.7.4 > > > -- > Kees Cook > Pixel Security
Re: [PATCH] nilfs2: remove inode->i_version initialization
On Mon, 30 Oct 2017 11:17:02 -0400, Jeff Layton wrote: > From: Jeff Layton <jlay...@redhat.com> > > It's never used in nilfs2. > > Signed-off-by: Jeff Layton <jlay...@redhat.com> > --- Applied, thank you. Ryusuke Konishi > fs/nilfs2/super.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c > index 4fc018dfcfae..3ce20cd44a20 100644 > --- a/fs/nilfs2/super.c > +++ b/fs/nilfs2/super.c > @@ -160,7 +160,6 @@ struct inode *nilfs_alloc_inode(struct super_block *sb) > ii->i_bh = NULL; > ii->i_state = 0; > ii->i_cno = 0; > - ii->vfs_inode.i_version = 1; > nilfs_mapping_init(>i_btnode_cache, >vfs_inode); > return >vfs_inode; > } > -- > 2.13.6 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] nilfs2: remove inode->i_version initialization
On Mon, 30 Oct 2017 11:17:02 -0400, Jeff Layton wrote: > From: Jeff Layton > > It's never used in nilfs2. > > Signed-off-by: Jeff Layton > --- Applied, thank you. Ryusuke Konishi > fs/nilfs2/super.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c > index 4fc018dfcfae..3ce20cd44a20 100644 > --- a/fs/nilfs2/super.c > +++ b/fs/nilfs2/super.c > @@ -160,7 +160,6 @@ struct inode *nilfs_alloc_inode(struct super_block *sb) > ii->i_bh = NULL; > ii->i_state = 0; > ii->i_cno = 0; > - ii->vfs_inode.i_version = 1; > nilfs_mapping_init(>i_btnode_cache, >vfs_inode); > return >vfs_inode; > } > -- > 2.13.6 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/4] nilfs2: align block comments of nilfs_sufile_truncate_range() at *
Fix the following checkpatch warning: WARNING: Block comments should align the * on each line #633: FILE: sufile.c:633: +/** + * nilfs_sufile_truncate_range - truncate range of segment array Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/sufile.c | 32 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c index 1541a1e..1341a41 100644 --- a/fs/nilfs2/sufile.c +++ b/fs/nilfs2/sufile.c @@ -630,22 +630,22 @@ void nilfs_sufile_do_set_error(struct inode *sufile, __u64 segnum, } /** - * nilfs_sufile_truncate_range - truncate range of segment array - * @sufile: inode of segment usage file - * @start: start segment number (inclusive) - * @end: end segment number (inclusive) - * - * Return Value: On success, 0 is returned. On error, one of the - * following negative error codes is returned. - * - * %-EIO - I/O error. - * - * %-ENOMEM - Insufficient amount of memory available. - * - * %-EINVAL - Invalid number of segments specified - * - * %-EBUSY - Dirty or active segments are present in the range - */ + * nilfs_sufile_truncate_range - truncate range of segment array + * @sufile: inode of segment usage file + * @start: start segment number (inclusive) + * @end: end segment number (inclusive) + * + * Return Value: On success, 0 is returned. On error, one of the + * following negative error codes is returned. + * + * %-EIO - I/O error. + * + * %-ENOMEM - Insufficient amount of memory available. + * + * %-EINVAL - Invalid number of segments specified + * + * %-EBUSY - Dirty or active segments are present in the range + */ static int nilfs_sufile_truncate_range(struct inode *sufile, __u64 start, __u64 end) { -- 1.8.3.1
[PATCH 0/4] nilfs2 updates
Hi Andrew, Please queue the following changes for the next merge window: Andreas Rohner (1): nilfs2: Fix race condition that causes file system corruption Elena Reshetova (1): fs, nilfs: convert nilfs_root.count from atomic_t to refcount_t Ryusuke Konishi (2): nilfs2: align block comments of nilfs_sufile_truncate_range() at * nilfs2: use octal for unreadable permission macro In this series, > nilfs2: Fix race condition that causes file system corruption fixes a file system corruption issue in some high loads. > fs, nilfs: convert nilfs_root.count from atomic_t to refcount_t introduces refcount_t type to nilfs. > nilfs2: align block comments of nilfs_sufile_truncate_range() at * > nilfs2: use octal for unreadable permission macro are style fixes, both of which are based on suggestions of recent checkpatch.pl. Thanks, Ryusuke Konishi -- fs/nilfs2/namei.c | 2 +- fs/nilfs2/segment.c | 6 -- fs/nilfs2/sufile.c| 32 fs/nilfs2/the_nilfs.c | 8 fs/nilfs2/the_nilfs.h | 5 +++-- 5 files changed, 28 insertions(+), 25 deletions(-)
[PATCH 3/4] nilfs2: align block comments of nilfs_sufile_truncate_range() at *
Fix the following checkpatch warning: WARNING: Block comments should align the * on each line #633: FILE: sufile.c:633: +/** + * nilfs_sufile_truncate_range - truncate range of segment array Signed-off-by: Ryusuke Konishi --- fs/nilfs2/sufile.c | 32 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c index 1541a1e..1341a41 100644 --- a/fs/nilfs2/sufile.c +++ b/fs/nilfs2/sufile.c @@ -630,22 +630,22 @@ void nilfs_sufile_do_set_error(struct inode *sufile, __u64 segnum, } /** - * nilfs_sufile_truncate_range - truncate range of segment array - * @sufile: inode of segment usage file - * @start: start segment number (inclusive) - * @end: end segment number (inclusive) - * - * Return Value: On success, 0 is returned. On error, one of the - * following negative error codes is returned. - * - * %-EIO - I/O error. - * - * %-ENOMEM - Insufficient amount of memory available. - * - * %-EINVAL - Invalid number of segments specified - * - * %-EBUSY - Dirty or active segments are present in the range - */ + * nilfs_sufile_truncate_range - truncate range of segment array + * @sufile: inode of segment usage file + * @start: start segment number (inclusive) + * @end: end segment number (inclusive) + * + * Return Value: On success, 0 is returned. On error, one of the + * following negative error codes is returned. + * + * %-EIO - I/O error. + * + * %-ENOMEM - Insufficient amount of memory available. + * + * %-EINVAL - Invalid number of segments specified + * + * %-EBUSY - Dirty or active segments are present in the range + */ static int nilfs_sufile_truncate_range(struct inode *sufile, __u64 start, __u64 end) { -- 1.8.3.1
[PATCH 0/4] nilfs2 updates
Hi Andrew, Please queue the following changes for the next merge window: Andreas Rohner (1): nilfs2: Fix race condition that causes file system corruption Elena Reshetova (1): fs, nilfs: convert nilfs_root.count from atomic_t to refcount_t Ryusuke Konishi (2): nilfs2: align block comments of nilfs_sufile_truncate_range() at * nilfs2: use octal for unreadable permission macro In this series, > nilfs2: Fix race condition that causes file system corruption fixes a file system corruption issue in some high loads. > fs, nilfs: convert nilfs_root.count from atomic_t to refcount_t introduces refcount_t type to nilfs. > nilfs2: align block comments of nilfs_sufile_truncate_range() at * > nilfs2: use octal for unreadable permission macro are style fixes, both of which are based on suggestions of recent checkpatch.pl. Thanks, Ryusuke Konishi -- fs/nilfs2/namei.c | 2 +- fs/nilfs2/segment.c | 6 -- fs/nilfs2/sufile.c| 32 fs/nilfs2/the_nilfs.c | 8 fs/nilfs2/the_nilfs.h | 5 +++-- 5 files changed, 28 insertions(+), 25 deletions(-)
[PATCH 2/4] fs, nilfs: convert nilfs_root.count from atomic_t to refcount_t
From: Elena Reshetova <elena.reshet...@intel.com> atomic_t variables are currently used to implement reference counters with the following properties: - counter is initialized to 1 using atomic_set() - a resource is freed upon counter reaching zero - once counter reaches zero, its further increments aren't allowed - counter schema uses basic atomic operations (set, inc, inc_not_zero, dec_and_test, etc.) Such atomic variables should be converted to a newly provided refcount_t type and API that prevents accidental counter overflows and underflows. This is important since overflows and underflows can lead to use-after-free situation and be exploitable. The variable nilfs_root.count is used as pure reference counter. Convert it to refcount_t and fix up the operations. Suggested-by: Kees Cook <keesc...@chromium.org> Reviewed-by: David Windsor <dwind...@gmail.com> Reviewed-by: Hans Liljestrand <ishkam...@gmail.com> Signed-off-by: Elena Reshetova <elena.reshet...@intel.com> Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/the_nilfs.c | 8 fs/nilfs2/the_nilfs.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 2dd75bf..afebb50 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c @@ -737,7 +737,7 @@ struct nilfs_root *nilfs_lookup_root(struct the_nilfs *nilfs, __u64 cno) } else if (cno > root->cno) { n = n->rb_right; } else { - atomic_inc(>count); + refcount_inc(>count); spin_unlock(>ns_cptree_lock); return root; } @@ -776,7 +776,7 @@ struct nilfs_root * } else if (cno > root->cno) { p = &(*p)->rb_right; } else { - atomic_inc(>count); + refcount_inc(>count); spin_unlock(>ns_cptree_lock); kfree(new); return root; @@ -786,7 +786,7 @@ struct nilfs_root * new->cno = cno; new->ifile = NULL; new->nilfs = nilfs; - atomic_set(>count, 1); + refcount_set(>count, 1); atomic64_set(>inodes_count, 0); atomic64_set(>blocks_count, 0); @@ -806,7 +806,7 @@ struct nilfs_root * void nilfs_put_root(struct nilfs_root *root) { - if (atomic_dec_and_test(>count)) { + if (refcount_dec_and_test(>count)) { struct the_nilfs *nilfs = root->nilfs; nilfs_sysfs_delete_snapshot_group(root); diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index b305c6f..883d732 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h @@ -27,6 +27,7 @@ #include #include #include +#include struct nilfs_sc_info; struct nilfs_sysfs_dev_subgroups; @@ -246,7 +247,7 @@ struct nilfs_root { __u64 cno; struct rb_node rb_node; - atomic_t count; + refcount_t count; struct the_nilfs *nilfs; struct inode *ifile; @@ -299,7 +300,7 @@ struct nilfs_root *nilfs_find_or_create_root(struct the_nilfs *nilfs, static inline void nilfs_get_root(struct nilfs_root *root) { - atomic_inc(>count); + refcount_inc(>count); } static inline int nilfs_valid_fs(struct the_nilfs *nilfs) -- 1.8.3.1
[PATCH 4/4] nilfs2: use octal for unreadable permission macro
Replace S_IRWXUGO with 0777 because symbolic permissions are considered harmful: https://lwn.net/Articles/696229/ Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 515d13c..1a2894a 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -150,7 +150,7 @@ static int nilfs_symlink(struct inode *dir, struct dentry *dentry, if (err) return err; - inode = nilfs_new_inode(dir, S_IFLNK | S_IRWXUGO); + inode = nilfs_new_inode(dir, S_IFLNK | 0777); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out; -- 1.8.3.1
[PATCH 2/4] fs, nilfs: convert nilfs_root.count from atomic_t to refcount_t
From: Elena Reshetova atomic_t variables are currently used to implement reference counters with the following properties: - counter is initialized to 1 using atomic_set() - a resource is freed upon counter reaching zero - once counter reaches zero, its further increments aren't allowed - counter schema uses basic atomic operations (set, inc, inc_not_zero, dec_and_test, etc.) Such atomic variables should be converted to a newly provided refcount_t type and API that prevents accidental counter overflows and underflows. This is important since overflows and underflows can lead to use-after-free situation and be exploitable. The variable nilfs_root.count is used as pure reference counter. Convert it to refcount_t and fix up the operations. Suggested-by: Kees Cook Reviewed-by: David Windsor Reviewed-by: Hans Liljestrand Signed-off-by: Elena Reshetova Signed-off-by: Ryusuke Konishi --- fs/nilfs2/the_nilfs.c | 8 fs/nilfs2/the_nilfs.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 2dd75bf..afebb50 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c @@ -737,7 +737,7 @@ struct nilfs_root *nilfs_lookup_root(struct the_nilfs *nilfs, __u64 cno) } else if (cno > root->cno) { n = n->rb_right; } else { - atomic_inc(>count); + refcount_inc(>count); spin_unlock(>ns_cptree_lock); return root; } @@ -776,7 +776,7 @@ struct nilfs_root * } else if (cno > root->cno) { p = &(*p)->rb_right; } else { - atomic_inc(>count); + refcount_inc(>count); spin_unlock(>ns_cptree_lock); kfree(new); return root; @@ -786,7 +786,7 @@ struct nilfs_root * new->cno = cno; new->ifile = NULL; new->nilfs = nilfs; - atomic_set(>count, 1); + refcount_set(>count, 1); atomic64_set(>inodes_count, 0); atomic64_set(>blocks_count, 0); @@ -806,7 +806,7 @@ struct nilfs_root * void nilfs_put_root(struct nilfs_root *root) { - if (atomic_dec_and_test(>count)) { + if (refcount_dec_and_test(>count)) { struct the_nilfs *nilfs = root->nilfs; nilfs_sysfs_delete_snapshot_group(root); diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index b305c6f..883d732 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h @@ -27,6 +27,7 @@ #include #include #include +#include struct nilfs_sc_info; struct nilfs_sysfs_dev_subgroups; @@ -246,7 +247,7 @@ struct nilfs_root { __u64 cno; struct rb_node rb_node; - atomic_t count; + refcount_t count; struct the_nilfs *nilfs; struct inode *ifile; @@ -299,7 +300,7 @@ struct nilfs_root *nilfs_find_or_create_root(struct the_nilfs *nilfs, static inline void nilfs_get_root(struct nilfs_root *root) { - atomic_inc(>count); + refcount_inc(>count); } static inline int nilfs_valid_fs(struct the_nilfs *nilfs) -- 1.8.3.1
[PATCH 4/4] nilfs2: use octal for unreadable permission macro
Replace S_IRWXUGO with 0777 because symbolic permissions are considered harmful: https://lwn.net/Articles/696229/ Signed-off-by: Ryusuke Konishi --- fs/nilfs2/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 515d13c..1a2894a 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -150,7 +150,7 @@ static int nilfs_symlink(struct inode *dir, struct dentry *dentry, if (err) return err; - inode = nilfs_new_inode(dir, S_IFLNK | S_IRWXUGO); + inode = nilfs_new_inode(dir, S_IFLNK | 0777); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out; -- 1.8.3.1
[PATCH 1/4] nilfs2: Fix race condition that causes file system corruption
From: Andreas Rohner <andreas.roh...@gmx.net> There is a race condition between the function nilfs_dirty_inode() and nilfs_set_file_dirty(). When a file is opened, nilfs_dirty_inode() is called to update the access timestamp in the inode. It calls __nilfs_mark_inode_dirty() in a separate transaction. __nilfs_mark_inode_dirty() caches the ifile buffer_head in the i_bh field of the inode info structure and marks it as dirty. After some data was written to the file in another transaction, the function nilfs_set_file_dirty() is called, which adds the inode to the ns_dirty_files list. Then the segment construction calls nilfs_segctor_collect_dirty_files(), which goes through the ns_dirty_files list and checks the i_bh field. If there is a cached buffer_head in i_bh it is not marked as dirty again. Since nilfs_dirty_inode() and nilfs_set_file_dirty() use separate transactions, it is possible that a segment construction that writes out the ifile occurs in-between the two. If this happens the inode is not on the ns_dirty_files list, but its ifile block is still marked as dirty and written out. In the next segment construction, the data for the file is written out and nilfs_bmap_propagate() updates the b-tree. Eventually the bmap root is written into the i_bh block, which is not dirty, because it was written out in another segment construction. As a result the bmap update can be lost, which leads to file system corruption. Either the virtual block address points to an unallocated DAT block, or the DAT entry will be reused for something different. The error can remain undetected for a long time. A typical error message would be one of the "bad btree" errors or a warning that a DAT entry could not be found. This bug can be reproduced reliably by a simple benchmark that creates and overwrites millions of 4k files. Signed-off-by: Andreas Rohner <andreas.roh...@gmx.net> Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> Tested-by: Andreas Rohner <andreas.roh...@gmx.net> Tested-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> Cc: sta...@vger.kernel.org --- fs/nilfs2/segment.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 70ded52..50e1295 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -1958,8 +1958,6 @@ static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci, err, ii->vfs_inode.i_ino); return err; } - mark_buffer_dirty(ibh); - nilfs_mdt_mark_dirty(ifile); spin_lock(>ns_inode_lock); if (likely(!ii->i_bh)) ii->i_bh = ibh; @@ -1968,6 +1966,10 @@ static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci, goto retry; } + // Always redirty the buffer to avoid race condition + mark_buffer_dirty(ii->i_bh); + nilfs_mdt_mark_dirty(ifile); + clear_bit(NILFS_I_QUEUED, >i_state); set_bit(NILFS_I_BUSY, >i_state); list_move_tail(>i_dirty, >sc_dirty_files); -- 1.8.3.1
[PATCH 1/4] nilfs2: Fix race condition that causes file system corruption
From: Andreas Rohner There is a race condition between the function nilfs_dirty_inode() and nilfs_set_file_dirty(). When a file is opened, nilfs_dirty_inode() is called to update the access timestamp in the inode. It calls __nilfs_mark_inode_dirty() in a separate transaction. __nilfs_mark_inode_dirty() caches the ifile buffer_head in the i_bh field of the inode info structure and marks it as dirty. After some data was written to the file in another transaction, the function nilfs_set_file_dirty() is called, which adds the inode to the ns_dirty_files list. Then the segment construction calls nilfs_segctor_collect_dirty_files(), which goes through the ns_dirty_files list and checks the i_bh field. If there is a cached buffer_head in i_bh it is not marked as dirty again. Since nilfs_dirty_inode() and nilfs_set_file_dirty() use separate transactions, it is possible that a segment construction that writes out the ifile occurs in-between the two. If this happens the inode is not on the ns_dirty_files list, but its ifile block is still marked as dirty and written out. In the next segment construction, the data for the file is written out and nilfs_bmap_propagate() updates the b-tree. Eventually the bmap root is written into the i_bh block, which is not dirty, because it was written out in another segment construction. As a result the bmap update can be lost, which leads to file system corruption. Either the virtual block address points to an unallocated DAT block, or the DAT entry will be reused for something different. The error can remain undetected for a long time. A typical error message would be one of the "bad btree" errors or a warning that a DAT entry could not be found. This bug can be reproduced reliably by a simple benchmark that creates and overwrites millions of 4k files. Signed-off-by: Andreas Rohner Signed-off-by: Ryusuke Konishi Tested-by: Andreas Rohner Tested-by: Ryusuke Konishi Cc: sta...@vger.kernel.org --- fs/nilfs2/segment.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 70ded52..50e1295 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -1958,8 +1958,6 @@ static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci, err, ii->vfs_inode.i_ino); return err; } - mark_buffer_dirty(ibh); - nilfs_mdt_mark_dirty(ifile); spin_lock(>ns_inode_lock); if (likely(!ii->i_bh)) ii->i_bh = ibh; @@ -1968,6 +1966,10 @@ static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci, goto retry; } + // Always redirty the buffer to avoid race condition + mark_buffer_dirty(ii->i_bh); + nilfs_mdt_mark_dirty(ifile); + clear_bit(NILFS_I_QUEUED, >i_state); set_bit(NILFS_I_BUSY, >i_state); list_move_tail(>i_dirty, >sc_dirty_files); -- 1.8.3.1
Re: [PATCH] fs, nilfs: convert nilfs_root.count from atomic_t to refcount_t
On 2017/10/20 19:51, Elena Reshetova wrote: atomic_t variables are currently used to implement reference counters with the following properties: - counter is initialized to 1 using atomic_set() - a resource is freed upon counter reaching zero - once counter reaches zero, its further increments aren't allowed - counter schema uses basic atomic operations (set, inc, inc_not_zero, dec_and_test, etc.) Such atomic variables should be converted to a newly provided refcount_t type and API that prevents accidental counter overflows and underflows. This is important since overflows and underflows can lead to use-after-free situation and be exploitable. The variable nilfs_root.count is used as pure reference counter. Convert it to refcount_t and fix up the operations. Suggested-by: Kees Cook <keesc...@chromium.org> Reviewed-by: David Windsor <dwind...@gmail.com> Reviewed-by: Hans Liljestrand <ishkam...@gmail.com> Signed-off-by: Elena Reshetova <elena.reshet...@intel.com> Applied, thank you. Ryusuke Konishi --- fs/nilfs2/the_nilfs.c | 8 fs/nilfs2/the_nilfs.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 2dd75bf..afebb50 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c @@ -737,7 +737,7 @@ struct nilfs_root *nilfs_lookup_root(struct the_nilfs *nilfs, __u64 cno) } else if (cno > root->cno) { n = n->rb_right; } else { - atomic_inc(>count); + refcount_inc(>count); spin_unlock(>ns_cptree_lock); return root; } @@ -776,7 +776,7 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno) } else if (cno > root->cno) { p = &(*p)->rb_right; } else { - atomic_inc(>count); + refcount_inc(>count); spin_unlock(>ns_cptree_lock); kfree(new); return root; @@ -786,7 +786,7 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno) new->cno = cno; new->ifile = NULL; new->nilfs = nilfs; - atomic_set(>count, 1); + refcount_set(>count, 1); atomic64_set(>inodes_count, 0); atomic64_set(>blocks_count, 0); @@ -806,7 +806,7 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno) void nilfs_put_root(struct nilfs_root *root) { - if (atomic_dec_and_test(>count)) { + if (refcount_dec_and_test(>count)) { struct the_nilfs *nilfs = root->nilfs; nilfs_sysfs_delete_snapshot_group(root); diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index b305c6f..883d732 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h @@ -27,6 +27,7 @@ #include #include #include +#include struct nilfs_sc_info; struct nilfs_sysfs_dev_subgroups; @@ -246,7 +247,7 @@ struct nilfs_root { __u64 cno; struct rb_node rb_node; - atomic_t count; + refcount_t count; struct the_nilfs *nilfs; struct inode *ifile; @@ -299,7 +300,7 @@ void nilfs_swap_super_block(struct the_nilfs *); static inline void nilfs_get_root(struct nilfs_root *root) { - atomic_inc(>count); + refcount_inc(>count); } static inline int nilfs_valid_fs(struct the_nilfs *nilfs)
Re: [PATCH] fs, nilfs: convert nilfs_root.count from atomic_t to refcount_t
On 2017/10/20 19:51, Elena Reshetova wrote: atomic_t variables are currently used to implement reference counters with the following properties: - counter is initialized to 1 using atomic_set() - a resource is freed upon counter reaching zero - once counter reaches zero, its further increments aren't allowed - counter schema uses basic atomic operations (set, inc, inc_not_zero, dec_and_test, etc.) Such atomic variables should be converted to a newly provided refcount_t type and API that prevents accidental counter overflows and underflows. This is important since overflows and underflows can lead to use-after-free situation and be exploitable. The variable nilfs_root.count is used as pure reference counter. Convert it to refcount_t and fix up the operations. Suggested-by: Kees Cook Reviewed-by: David Windsor Reviewed-by: Hans Liljestrand Signed-off-by: Elena Reshetova Applied, thank you. Ryusuke Konishi --- fs/nilfs2/the_nilfs.c | 8 fs/nilfs2/the_nilfs.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 2dd75bf..afebb50 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c @@ -737,7 +737,7 @@ struct nilfs_root *nilfs_lookup_root(struct the_nilfs *nilfs, __u64 cno) } else if (cno > root->cno) { n = n->rb_right; } else { - atomic_inc(>count); + refcount_inc(>count); spin_unlock(>ns_cptree_lock); return root; } @@ -776,7 +776,7 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno) } else if (cno > root->cno) { p = &(*p)->rb_right; } else { - atomic_inc(>count); + refcount_inc(>count); spin_unlock(>ns_cptree_lock); kfree(new); return root; @@ -786,7 +786,7 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno) new->cno = cno; new->ifile = NULL; new->nilfs = nilfs; - atomic_set(>count, 1); + refcount_set(>count, 1); atomic64_set(>inodes_count, 0); atomic64_set(>blocks_count, 0); @@ -806,7 +806,7 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno) void nilfs_put_root(struct nilfs_root *root) { - if (atomic_dec_and_test(>count)) { + if (refcount_dec_and_test(>count)) { struct the_nilfs *nilfs = root->nilfs; nilfs_sysfs_delete_snapshot_group(root); diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index b305c6f..883d732 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h @@ -27,6 +27,7 @@ #include #include #include +#include struct nilfs_sc_info; struct nilfs_sysfs_dev_subgroups; @@ -246,7 +247,7 @@ struct nilfs_root { __u64 cno; struct rb_node rb_node; - atomic_t count; + refcount_t count; struct the_nilfs *nilfs; struct inode *ifile; @@ -299,7 +300,7 @@ void nilfs_swap_super_block(struct the_nilfs *); static inline void nilfs_get_root(struct nilfs_root *root) { - atomic_inc(>count); + refcount_inc(>count); } static inline int nilfs_valid_fs(struct the_nilfs *nilfs)
Re: [PATCH 1/3] nilfs2: set the mapping error when calling SetPageError on writeback
On Sun, 5 Mar 2017 08:35:33 -0500, Jeff Layton <jlay...@redhat.com> wrote: > In a later patch, we're going to want to make the fsync codepath not do > a TestClearPageError call as that can override the error set in the > address space. To do that though, we need to ensure that filesystems > that are relying on the PG_error bit for reporting writeback errors > also set an error in the address space. > > The only place I've found that looks potentially problematic is this > spot in nilfs2. Ensure that it sets an error in the mapping in addition > to setting PageError. > > Signed-off-by: Jeff Layton <jlay...@redhat.com> Acked-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> Agreed that nilfs2 needs this if the successive patch is applied. Thanks, Ryusuke Konishi > --- > fs/nilfs2/segment.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index bedcae2c28e6..c1041b07060e 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -1743,6 +1743,7 @@ static void nilfs_end_page_io(struct page *page, int > err) > } else { > __set_page_dirty_nobuffers(page); > SetPageError(page); > + mapping_set_error(page_mapping(page), err); > } > > end_page_writeback(page); > -- > 2.9.3 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majord...@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: mailto:"d...@kvack.org;> em...@kvack.org
Re: [PATCH 1/3] nilfs2: set the mapping error when calling SetPageError on writeback
On Sun, 5 Mar 2017 08:35:33 -0500, Jeff Layton wrote: > In a later patch, we're going to want to make the fsync codepath not do > a TestClearPageError call as that can override the error set in the > address space. To do that though, we need to ensure that filesystems > that are relying on the PG_error bit for reporting writeback errors > also set an error in the address space. > > The only place I've found that looks potentially problematic is this > spot in nilfs2. Ensure that it sets an error in the mapping in addition > to setting PageError. > > Signed-off-by: Jeff Layton Acked-by: Ryusuke Konishi Agreed that nilfs2 needs this if the successive patch is applied. Thanks, Ryusuke Konishi > --- > fs/nilfs2/segment.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index bedcae2c28e6..c1041b07060e 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -1743,6 +1743,7 @@ static void nilfs_end_page_io(struct page *page, int > err) > } else { > __set_page_dirty_nobuffers(page); > SetPageError(page); > + mapping_set_error(page_mapping(page), err); > } > > end_page_writeback(page); > -- > 2.9.3 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majord...@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: mailto:"d...@kvack.org;> em...@kvack.org
Re: + nilfs2-use-i_blocksize.patch added to -mm tree
Hi, Andrew On Mon, 23 Jan 2017 14:55:24 -0800, Andrew Morton wrote: > > The patch titled > Subject: nilfs2: use i_blocksize() > has been added to the -mm tree. Its filename is > nilfs2-use-i_blocksize.patch > > This patch should soon appear at > http://ozlabs.org/~akpm/mmots/broken-out/nilfs2-use-i_blocksize.patch > and later at > http://ozlabs.org/~akpm/mmotm/broken-out/nilfs2-use-i_blocksize.patch Could you move this patch to the back of fs-add-i_blocksize.patch in the "post-linux-next" section ? This patch depends on fs-add-i_blocksize.patch and will break build without it. Thanks, Ryusuke Konishi > > Before you just go and hit "reply", please: >a) Consider who else should be cc'ed >b) Prefer to cc a suitable mailing list as well >c) Ideally: find the original patch on the mailing list and do a > reply-to-all to that, adding suitable additional cc's > > *** Remember to use Documentation/SubmitChecklist when testing your code *** > > The -mm tree is included into linux-next and is updated > there every 3-4 working days > > -- > From: Geliang Tang <geliangt...@gmail.com> > Subject: nilfs2: use i_blocksize() > > Since i_blocksize() helper has been defined in fs.h, use it instead > of open-coding. > > Link: > http://lkml.kernel.org/r/1485184655-3895-3-git-send-email-konishi.ryus...@lab.ntt.co.jp > Signed-off-by: Geliang Tang <geliangt...@gmail.com> > Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> > Signed-off-by: Andrew Morton <a...@linux-foundation.org> > --- > > fs/nilfs2/alloc.c |2 +- > fs/nilfs2/btree.c |2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff -puN fs/nilfs2/alloc.c~nilfs2-use-i_blocksize fs/nilfs2/alloc.c > --- a/fs/nilfs2/alloc.c~nilfs2-use-i_blocksize > +++ a/fs/nilfs2/alloc.c > @@ -34,7 +34,7 @@ > static inline unsigned long > nilfs_palloc_groups_per_desc_block(const struct inode *inode) > { > - return (1UL << inode->i_blkbits) / > + return i_blocksize(inode) / > sizeof(struct nilfs_palloc_group_desc); > } > > diff -puN fs/nilfs2/btree.c~nilfs2-use-i_blocksize fs/nilfs2/btree.c > --- a/fs/nilfs2/btree.c~nilfs2-use-i_blocksize > +++ a/fs/nilfs2/btree.c > @@ -119,7 +119,7 @@ nilfs_btree_node_set_nchildren(struct ni > > static int nilfs_btree_node_size(const struct nilfs_bmap *btree) > { > - return 1 << btree->b_inode->i_blkbits; > + return i_blocksize(btree->b_inode); > } > > static int nilfs_btree_nchildren_per_block(const struct nilfs_bmap *btree) > _ > > Patches currently in -mm which might be from geliangt...@gmail.com are > > mm-vmallocc-use-rb_entry_safe.patch > writeback-use-rb_entry.patch > proc-use-rb_entry.patch > nilfs2-use-nilfs_btree_node_size.patch > nilfs2-use-i_blocksize.patch > fs-add-i_blocksize-fix.patch > > -- > To unsubscribe from this list: send the line "unsubscribe mm-commits" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: + nilfs2-use-i_blocksize.patch added to -mm tree
Hi, Andrew On Mon, 23 Jan 2017 14:55:24 -0800, Andrew Morton wrote: > > The patch titled > Subject: nilfs2: use i_blocksize() > has been added to the -mm tree. Its filename is > nilfs2-use-i_blocksize.patch > > This patch should soon appear at > http://ozlabs.org/~akpm/mmots/broken-out/nilfs2-use-i_blocksize.patch > and later at > http://ozlabs.org/~akpm/mmotm/broken-out/nilfs2-use-i_blocksize.patch Could you move this patch to the back of fs-add-i_blocksize.patch in the "post-linux-next" section ? This patch depends on fs-add-i_blocksize.patch and will break build without it. Thanks, Ryusuke Konishi > > Before you just go and hit "reply", please: >a) Consider who else should be cc'ed >b) Prefer to cc a suitable mailing list as well >c) Ideally: find the original patch on the mailing list and do a > reply-to-all to that, adding suitable additional cc's > > *** Remember to use Documentation/SubmitChecklist when testing your code *** > > The -mm tree is included into linux-next and is updated > there every 3-4 working days > > -- > From: Geliang Tang > Subject: nilfs2: use i_blocksize() > > Since i_blocksize() helper has been defined in fs.h, use it instead > of open-coding. > > Link: > http://lkml.kernel.org/r/1485184655-3895-3-git-send-email-konishi.ryus...@lab.ntt.co.jp > Signed-off-by: Geliang Tang > Signed-off-by: Ryusuke Konishi > Signed-off-by: Andrew Morton > --- > > fs/nilfs2/alloc.c |2 +- > fs/nilfs2/btree.c |2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff -puN fs/nilfs2/alloc.c~nilfs2-use-i_blocksize fs/nilfs2/alloc.c > --- a/fs/nilfs2/alloc.c~nilfs2-use-i_blocksize > +++ a/fs/nilfs2/alloc.c > @@ -34,7 +34,7 @@ > static inline unsigned long > nilfs_palloc_groups_per_desc_block(const struct inode *inode) > { > - return (1UL << inode->i_blkbits) / > + return i_blocksize(inode) / > sizeof(struct nilfs_palloc_group_desc); > } > > diff -puN fs/nilfs2/btree.c~nilfs2-use-i_blocksize fs/nilfs2/btree.c > --- a/fs/nilfs2/btree.c~nilfs2-use-i_blocksize > +++ a/fs/nilfs2/btree.c > @@ -119,7 +119,7 @@ nilfs_btree_node_set_nchildren(struct ni > > static int nilfs_btree_node_size(const struct nilfs_bmap *btree) > { > - return 1 << btree->b_inode->i_blkbits; > + return i_blocksize(btree->b_inode); > } > > static int nilfs_btree_nchildren_per_block(const struct nilfs_bmap *btree) > _ > > Patches currently in -mm which might be from geliangt...@gmail.com are > > mm-vmallocc-use-rb_entry_safe.patch > writeback-use-rb_entry.patch > proc-use-rb_entry.patch > nilfs2-use-nilfs_btree_node_size.patch > nilfs2-use-i_blocksize.patch > fs-add-i_blocksize-fix.patch > > -- > To unsubscribe from this list: send the line "unsubscribe mm-commits" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH -mm 2/2] nilfs2: use i_blocksize()
From: Geliang Tang <geliangt...@gmail.com> Since i_blocksize() helper has been defined in fs.h, use it instead of open-coding. Signed-off-by: Geliang Tang <geliangt...@gmail.com> Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/alloc.c | 2 +- fs/nilfs2/btree.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c index 2c90e28..03b8ba9 100644 --- a/fs/nilfs2/alloc.c +++ b/fs/nilfs2/alloc.c @@ -34,7 +34,7 @@ static inline unsigned long nilfs_palloc_groups_per_desc_block(const struct inode *inode) { - return (1UL << inode->i_blkbits) / + return i_blocksize(inode) / sizeof(struct nilfs_palloc_group_desc); } diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 9c7ea17..06ffa13 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c @@ -119,7 +119,7 @@ static int nilfs_btree_node_get_nchildren(const struct nilfs_btree_node *node) static int nilfs_btree_node_size(const struct nilfs_bmap *btree) { - return 1 << btree->b_inode->i_blkbits; + return i_blocksize(btree->b_inode); } static int nilfs_btree_nchildren_per_block(const struct nilfs_bmap *btree) -- 1.8.3.1
[PATCH -mm 2/2] nilfs2: use i_blocksize()
From: Geliang Tang Since i_blocksize() helper has been defined in fs.h, use it instead of open-coding. Signed-off-by: Geliang Tang Signed-off-by: Ryusuke Konishi --- fs/nilfs2/alloc.c | 2 +- fs/nilfs2/btree.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c index 2c90e28..03b8ba9 100644 --- a/fs/nilfs2/alloc.c +++ b/fs/nilfs2/alloc.c @@ -34,7 +34,7 @@ static inline unsigned long nilfs_palloc_groups_per_desc_block(const struct inode *inode) { - return (1UL << inode->i_blkbits) / + return i_blocksize(inode) / sizeof(struct nilfs_palloc_group_desc); } diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 9c7ea17..06ffa13 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c @@ -119,7 +119,7 @@ static int nilfs_btree_node_get_nchildren(const struct nilfs_btree_node *node) static int nilfs_btree_node_size(const struct nilfs_bmap *btree) { - return 1 << btree->b_inode->i_blkbits; + return i_blocksize(btree->b_inode); } static int nilfs_btree_nchildren_per_block(const struct nilfs_bmap *btree) -- 1.8.3.1
[PATCH -mm 0/2] nilfs2 minor changes
Hi Andrew, Please queue the following changes for the next merge window: Geliang Tang (2): nilfs2: use nilfs_btree_node_size() nilfs2: use i_blocksize() where "nilfs2: use i_blocksize()" requires the patch "fs: add i_blocksize()" which resides in -mm tree. Meanwhile "nilfs2: use nilfs_btree_node_size()" is applicable independently. Thanks, Ryusuke Konishi -- fs/nilfs2/alloc.c | 2 +- fs/nilfs2/btree.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
[PATCH -mm 0/2] nilfs2 minor changes
Hi Andrew, Please queue the following changes for the next merge window: Geliang Tang (2): nilfs2: use nilfs_btree_node_size() nilfs2: use i_blocksize() where "nilfs2: use i_blocksize()" requires the patch "fs: add i_blocksize()" which resides in -mm tree. Meanwhile "nilfs2: use nilfs_btree_node_size()" is applicable independently. Thanks, Ryusuke Konishi -- fs/nilfs2/alloc.c | 2 +- fs/nilfs2/btree.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
[PATCH -mm 1/2] nilfs2: use nilfs_btree_node_size()
From: Geliang Tang <geliangt...@gmail.com> Use nilfs_btree_node_size() instead of open-coding. Signed-off-by: Geliang Tang <geliangt...@gmail.com> Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 2e315f9..9c7ea17 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c @@ -1870,7 +1870,7 @@ int nilfs_btree_convert_and_insert(struct nilfs_bmap *btree, di = ni = NULL; } else if ((n + 1) <= NILFS_BTREE_NODE_NCHILDREN_MAX( - 1 << btree->b_inode->i_blkbits)) { + nilfs_btree_node_size(btree))) { di = ni = } else { -- 1.8.3.1
[PATCH -mm 1/2] nilfs2: use nilfs_btree_node_size()
From: Geliang Tang Use nilfs_btree_node_size() instead of open-coding. Signed-off-by: Geliang Tang Signed-off-by: Ryusuke Konishi --- fs/nilfs2/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 2e315f9..9c7ea17 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c @@ -1870,7 +1870,7 @@ int nilfs_btree_convert_and_insert(struct nilfs_bmap *btree, di = ni = NULL; } else if ((n + 1) <= NILFS_BTREE_NODE_NCHILDREN_MAX( - 1 << btree->b_inode->i_blkbits)) { + nilfs_btree_node_size(btree))) { di = ni = } else { -- 1.8.3.1
Re: [PATCH 1/2] nilfs2: use i_blocksize()
On Fri, 20 Jan 2017 22:34:57 +0800, Geliang Tang wrote: > Since i_blocksize() helper has been defined in fs.h, use it instead > of open-coding. > > Signed-off-by: Geliang Tang <geliangt...@gmail.com> i_blocksize() doesn't exist in the mainline kernel. This needs another patch titled "fs: add i_blocksize()" which I found in the latest -mm tree. I will send this to the -mm tree along with this dependency. Regards, Ryusuke Konishi > --- > fs/nilfs2/alloc.c | 2 +- > fs/nilfs2/btree.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c > index 2c90e28..03b8ba9 100644 > --- a/fs/nilfs2/alloc.c > +++ b/fs/nilfs2/alloc.c > @@ -34,7 +34,7 @@ > static inline unsigned long > nilfs_palloc_groups_per_desc_block(const struct inode *inode) > { > - return (1UL << inode->i_blkbits) / > + return i_blocksize(inode) / > sizeof(struct nilfs_palloc_group_desc); > } > > diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c > index 2e315f9..d75238a 100644 > --- a/fs/nilfs2/btree.c > +++ b/fs/nilfs2/btree.c > @@ -119,7 +119,7 @@ nilfs_btree_node_set_nchildren(struct nilfs_btree_node > *node, int nchildren) > > static int nilfs_btree_node_size(const struct nilfs_bmap *btree) > { > - return 1 << btree->b_inode->i_blkbits; > + return i_blocksize(btree->b_inode); > } > > static int nilfs_btree_nchildren_per_block(const struct nilfs_bmap *btree) > -- > 2.9.3 >
Re: [PATCH 1/2] nilfs2: use i_blocksize()
On Fri, 20 Jan 2017 22:34:57 +0800, Geliang Tang wrote: > Since i_blocksize() helper has been defined in fs.h, use it instead > of open-coding. > > Signed-off-by: Geliang Tang i_blocksize() doesn't exist in the mainline kernel. This needs another patch titled "fs: add i_blocksize()" which I found in the latest -mm tree. I will send this to the -mm tree along with this dependency. Regards, Ryusuke Konishi > --- > fs/nilfs2/alloc.c | 2 +- > fs/nilfs2/btree.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c > index 2c90e28..03b8ba9 100644 > --- a/fs/nilfs2/alloc.c > +++ b/fs/nilfs2/alloc.c > @@ -34,7 +34,7 @@ > static inline unsigned long > nilfs_palloc_groups_per_desc_block(const struct inode *inode) > { > - return (1UL << inode->i_blkbits) / > + return i_blocksize(inode) / > sizeof(struct nilfs_palloc_group_desc); > } > > diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c > index 2e315f9..d75238a 100644 > --- a/fs/nilfs2/btree.c > +++ b/fs/nilfs2/btree.c > @@ -119,7 +119,7 @@ nilfs_btree_node_set_nchildren(struct nilfs_btree_node > *node, int nchildren) > > static int nilfs_btree_node_size(const struct nilfs_bmap *btree) > { > - return 1 << btree->b_inode->i_blkbits; > + return i_blocksize(btree->b_inode); > } > > static int nilfs_btree_nchildren_per_block(const struct nilfs_bmap *btree) > -- > 2.9.3 >
Re: [PATCH 2/2] nilfs2: use nilfs_btree_node_size()
On Fri, 20 Jan 2017 22:34:58 +0800, Geliang Tang wrote: > Use nilfs_btree_node_size() instead of open-coding. > > Signed-off-by: Geliang Tang <geliangt...@gmail.com> Applied, thanks. Ryusuke Konishi > --- > fs/nilfs2/btree.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c > index d75238a..06ffa13 100644 > --- a/fs/nilfs2/btree.c > +++ b/fs/nilfs2/btree.c > @@ -1870,7 +1870,7 @@ int nilfs_btree_convert_and_insert(struct nilfs_bmap > *btree, > di = > ni = NULL; > } else if ((n + 1) <= NILFS_BTREE_NODE_NCHILDREN_MAX( > -1 << btree->b_inode->i_blkbits)) { > +nilfs_btree_node_size(btree))) { > di = > ni = > } else { > -- > 2.9.3 >
Re: [PATCH 2/2] nilfs2: use nilfs_btree_node_size()
On Fri, 20 Jan 2017 22:34:58 +0800, Geliang Tang wrote: > Use nilfs_btree_node_size() instead of open-coding. > > Signed-off-by: Geliang Tang Applied, thanks. Ryusuke Konishi > --- > fs/nilfs2/btree.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c > index d75238a..06ffa13 100644 > --- a/fs/nilfs2/btree.c > +++ b/fs/nilfs2/btree.c > @@ -1870,7 +1870,7 @@ int nilfs_btree_convert_and_insert(struct nilfs_bmap > *btree, > di = > ni = NULL; > } else if ((n + 1) <= NILFS_BTREE_NODE_NCHILDREN_MAX( > -1 << btree->b_inode->i_blkbits)) { > +nilfs_btree_node_size(btree))) { > di = > ni = > } else { > -- > 2.9.3 >
[PATCH 1/1] fs/nilfs2: Fix potential underflow in call to crc32_le
From: Torsten Hilbrich <torsten.hilbr...@secunet.com> The value bytes comes from the filesystem which is about to be mounted. We cannot trust that the value is always in the range we expect it to be. Check its value before using it to calculate the length for the crc32_le call. It value must be larger (or equal) sumoff + 4. This fixes a kernel bug when accidentially mounting an image file which had the nilfs2 magic value 0x3434 at the right offset 0x406 by chance. The bytes 0x01 0x00 were stored at 0x408 and were interpreted as a s_bytes value of 1. This caused an underflow when substracting sumoff + 4 (20) in the call to crc32_le. [201699.185465] BUG: unable to handle kernel paging request at 88021e60 [201699.186111] IP: [] crc32_le+0x36/0x100 ... [201699.206202] Call Trace: [201699.206982] [] nilfs_valid_sb.part.5+0x52/0x60 [nilfs2] [201699.207773] [] nilfs_load_super_block+0x142/0x300 [nilfs2] [201699.208564] [] ? set_blocksize+0x9d/0xd0 [201699.209355] [] init_nilfs+0x60/0x390 [nilfs2] [201699.210160] [] nilfs_mount+0x302/0x520 [nilfs2] [201699.210930] [] ? pcpu_alloc+0x385/0x670 [201699.211685] [] mount_fs+0x38/0x160 [201699.212413] [] ? __alloc_percpu+0x15/0x20 [201699.213151] [] vfs_kern_mount+0x67/0x110 [201699.213898] [] do_mount+0x269/0xe00 [201699.214671] [] ? mntput+0x24/0x40 [201699.215432] [] ? __kmalloc_track_caller+0x1b4/0x250 [201699.216207] [] ? __fput+0x190/0x220 [201699.216987] [] ? memdup_user+0x42/0x70 [201699.21] [] SyS_mount+0x9f/0x100 [201699.218595] [] entry_SYSCALL_64_fastpath+0x16/0x71 Signed-off-by: Torsten Hilbrich <torsten.hilbr...@secunet.com> Tested-by: Torsten Hilbrich <torsten.hilbr...@secunet.com> Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> Cc: sta...@vger.kernel.org --- fs/nilfs2/the_nilfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 809bd2d..e9fd241 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c @@ -439,7 +439,7 @@ static int nilfs_valid_sb(struct nilfs_super_block *sbp) if (!sbp || le16_to_cpu(sbp->s_magic) != NILFS_SUPER_MAGIC) return 0; bytes = le16_to_cpu(sbp->s_bytes); - if (bytes > BLOCK_SIZE) + if (bytes < sumoff + 4 || bytes > BLOCK_SIZE) return 0; crc = crc32_le(le32_to_cpu(sbp->s_crc_seed), (unsigned char *)sbp, sumoff); -- 1.8.3.1
[PATCH 1/1] fs/nilfs2: Fix potential underflow in call to crc32_le
From: Torsten Hilbrich The value bytes comes from the filesystem which is about to be mounted. We cannot trust that the value is always in the range we expect it to be. Check its value before using it to calculate the length for the crc32_le call. It value must be larger (or equal) sumoff + 4. This fixes a kernel bug when accidentially mounting an image file which had the nilfs2 magic value 0x3434 at the right offset 0x406 by chance. The bytes 0x01 0x00 were stored at 0x408 and were interpreted as a s_bytes value of 1. This caused an underflow when substracting sumoff + 4 (20) in the call to crc32_le. [201699.185465] BUG: unable to handle kernel paging request at 88021e60 [201699.186111] IP: [] crc32_le+0x36/0x100 ... [201699.206202] Call Trace: [201699.206982] [] nilfs_valid_sb.part.5+0x52/0x60 [nilfs2] [201699.207773] [] nilfs_load_super_block+0x142/0x300 [nilfs2] [201699.208564] [] ? set_blocksize+0x9d/0xd0 [201699.209355] [] init_nilfs+0x60/0x390 [nilfs2] [201699.210160] [] nilfs_mount+0x302/0x520 [nilfs2] [201699.210930] [] ? pcpu_alloc+0x385/0x670 [201699.211685] [] mount_fs+0x38/0x160 [201699.212413] [] ? __alloc_percpu+0x15/0x20 [201699.213151] [] vfs_kern_mount+0x67/0x110 [201699.213898] [] do_mount+0x269/0xe00 [201699.214671] [] ? mntput+0x24/0x40 [201699.215432] [] ? __kmalloc_track_caller+0x1b4/0x250 [201699.216207] [] ? __fput+0x190/0x220 [201699.216987] [] ? memdup_user+0x42/0x70 [201699.21] [] SyS_mount+0x9f/0x100 [201699.218595] [] entry_SYSCALL_64_fastpath+0x16/0x71 Signed-off-by: Torsten Hilbrich Tested-by: Torsten Hilbrich Signed-off-by: Ryusuke Konishi Cc: sta...@vger.kernel.org --- fs/nilfs2/the_nilfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 809bd2d..e9fd241 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c @@ -439,7 +439,7 @@ static int nilfs_valid_sb(struct nilfs_super_block *sbp) if (!sbp || le16_to_cpu(sbp->s_magic) != NILFS_SUPER_MAGIC) return 0; bytes = le16_to_cpu(sbp->s_bytes); - if (bytes > BLOCK_SIZE) + if (bytes < sumoff + 4 || bytes > BLOCK_SIZE) return 0; crc = crc32_le(le32_to_cpu(sbp->s_crc_seed), (unsigned char *)sbp, sumoff); -- 1.8.3.1
[PATCH 0/1] fs/nilfs2: Fix potential underflow in call to crc32_le
Hi Andrew, Please send the following patch to upstream (hopefully in this cycle). It fixes a memory overrun issue due to incomplete sanity check of on-disk super block size information, which can result in a kernel panic, for instance, in the case where a non-nilfs volume is accidentally mounted through nilfs2. The patch is applicable to the mainline as well as -mm tree. Thanks, Ryusuke Konishi -- Torsten Hilbrich (1): fs/nilfs2: Fix potential underflow in call to crc32_le fs/nilfs2/the_nilfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH 0/1] fs/nilfs2: Fix potential underflow in call to crc32_le
Hi Andrew, Please send the following patch to upstream (hopefully in this cycle). It fixes a memory overrun issue due to incomplete sanity check of on-disk super block size information, which can result in a kernel panic, for instance, in the case where a non-nilfs volume is accidentally mounted through nilfs2. The patch is applicable to the mainline as well as -mm tree. Thanks, Ryusuke Konishi -- Torsten Hilbrich (1): fs/nilfs2: Fix potential underflow in call to crc32_le fs/nilfs2/the_nilfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH] nilfs: avoid warning about unused variables
On Wed, 15 Jun 2016 22:19:41 +0200, Arnd Bergmann <a...@arndb.de> wrote: > The newly added nilfs_msg() infrastructure caused a warning in > nilfs_clear_dirty_page() when it is disabled: > > fs/nilfs2/page.c: In function 'nilfs_clear_dirty_page': > fs/nilfs2/page.c:402:22: error: unused variable 'sb' [-Werror=unused-variable] > struct super_block *sb = inode->i_sb; > > We can avoid the warning by adding a cast to void for the first > argument of the macro. > > Signed-off-by: Arnd Bergmann <a...@arndb.de> > Fixes: aede53d223f0 ("nilfs2: replace nilfs_warning() with nilfs_msg()") Thanks for the catch! Regards, Ryusuke Konishi > --- > fs/nilfs2/nilfs.h | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h > index b7064faef217..46fbd4e00315 100644 > --- a/fs/nilfs2/nilfs.h > +++ b/fs/nilfs2/nilfs.h > @@ -317,7 +317,10 @@ void __nilfs_error(struct super_block *sb, const char > *function, > #else > > #define nilfs_msg(sb, level, fmt, ...) > \ > - no_printk(fmt, ##__VA_ARGS__) > + do {\ > + no_printk(fmt, ##__VA_ARGS__); \ > + (void)(sb); \ > + } while (0) > #define nilfs_error(sb, fmt, ...)\ > do {\ > no_printk(fmt, ##__VA_ARGS__); \ > -- > 2.9.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] nilfs: avoid warning about unused variables
On Wed, 15 Jun 2016 22:19:41 +0200, Arnd Bergmann wrote: > The newly added nilfs_msg() infrastructure caused a warning in > nilfs_clear_dirty_page() when it is disabled: > > fs/nilfs2/page.c: In function 'nilfs_clear_dirty_page': > fs/nilfs2/page.c:402:22: error: unused variable 'sb' [-Werror=unused-variable] > struct super_block *sb = inode->i_sb; > > We can avoid the warning by adding a cast to void for the first > argument of the macro. > > Signed-off-by: Arnd Bergmann > Fixes: aede53d223f0 ("nilfs2: replace nilfs_warning() with nilfs_msg()") Thanks for the catch! Regards, Ryusuke Konishi > --- > fs/nilfs2/nilfs.h | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h > index b7064faef217..46fbd4e00315 100644 > --- a/fs/nilfs2/nilfs.h > +++ b/fs/nilfs2/nilfs.h > @@ -317,7 +317,10 @@ void __nilfs_error(struct super_block *sb, const char > *function, > #else > > #define nilfs_msg(sb, level, fmt, ...) > \ > - no_printk(fmt, ##__VA_ARGS__) > + do {\ > + no_printk(fmt, ##__VA_ARGS__); \ > + (void)(sb); \ > + } while (0) > #define nilfs_error(sb, fmt, ...)\ > do {\ > no_printk(fmt, ##__VA_ARGS__); \ > -- > 2.9.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] nilfs2: move ioctl interface and disk layout to uapi separately
On Tue, 14 Jun 2016 15:29:52 -0700, Andrew Morton wrote: > On Mon, 13 Jun 2016 22:45:07 +0900 Ryusuke Konishi > <konishi.ryus...@lab.ntt.co.jp> wrote: > >> The header file "include/linux/nilfs2_fs.h" is composed of parts for >> ioctl and disk format, and both are intended to be shared with user >> space programs. >> >> This moves them to the uapi directory "include/uapi/linux" splitting >> the file to "nilfs2_api.h" and "nilfs2_ondisk.h". The following minor >> changes are accompanied by this migration: >> >> - nilfs_direct_node struct in nilfs2/direct.h is converged to >>nilfs2_ondisk.h because it's an on-disk structure. >> - inline functions nilfs_rec_len_from_disk() and >>nilfs_rec_len_to_disk() are moved to nilfs2/dir.c. >> >> ... >> >> +static inline __le16 nilfs_rec_len_to_disk(unsigned int len) >> +{ >> +#if (PAGE_SIZE >= 65536) >> +if (len == (1 << 16)) >> +return cpu_to_le16(NILFS_MAX_REC_LEN); >> + >> +BUG_ON(len > (1 << 16)); > > Is there any way in which the mount of a corrupted filesystem could > trigger this BUG? If so, that would be bad. This BUG is never triggered in theory because the length is limited to "chunk_size" by nilfs_check_page(), nilfs_make_empty(), etc, and the chunk_size is limited to s_blocksize which is verified to be less than or equal to NILFS_MAX_BLOCK_SIZE (= 65536) at mount time. This time I didn't come up with a simple way to remove it - I hope to clean it when refactoring the directory implementation. Thanks, Ryusuke Konishi >> +#endif >> +return cpu_to_le16(len); >> +}
Re: [PATCH 3/3] nilfs2: move ioctl interface and disk layout to uapi separately
On Tue, 14 Jun 2016 15:29:52 -0700, Andrew Morton wrote: > On Mon, 13 Jun 2016 22:45:07 +0900 Ryusuke Konishi > wrote: > >> The header file "include/linux/nilfs2_fs.h" is composed of parts for >> ioctl and disk format, and both are intended to be shared with user >> space programs. >> >> This moves them to the uapi directory "include/uapi/linux" splitting >> the file to "nilfs2_api.h" and "nilfs2_ondisk.h". The following minor >> changes are accompanied by this migration: >> >> - nilfs_direct_node struct in nilfs2/direct.h is converged to >>nilfs2_ondisk.h because it's an on-disk structure. >> - inline functions nilfs_rec_len_from_disk() and >>nilfs_rec_len_to_disk() are moved to nilfs2/dir.c. >> >> ... >> >> +static inline __le16 nilfs_rec_len_to_disk(unsigned int len) >> +{ >> +#if (PAGE_SIZE >= 65536) >> +if (len == (1 << 16)) >> +return cpu_to_le16(NILFS_MAX_REC_LEN); >> + >> +BUG_ON(len > (1 << 16)); > > Is there any way in which the mount of a corrupted filesystem could > trigger this BUG? If so, that would be bad. This BUG is never triggered in theory because the length is limited to "chunk_size" by nilfs_check_page(), nilfs_make_empty(), etc, and the chunk_size is limited to s_blocksize which is verified to be less than or equal to NILFS_MAX_BLOCK_SIZE (= 65536) at mount time. This time I didn't come up with a simple way to remove it - I hope to clean it when refactoring the directory implementation. Thanks, Ryusuke Konishi >> +#endif >> +return cpu_to_le16(len); >> +}
[PATCH 0/3] nilfs2 additional updates
Hi Andrew, please add the following changes for the next merge window: Ryusuke Konishi (3): nilfs2: fix misuse of a semaphore in sysfs code nilfs2: use BIT() macro nilfs2: move ioctl interface and disk layout to uapi separately In this series, > nilfs2: fix misuse of a semaphore in sysfs code corrects, as its name suggests, wrong use of a semaphore, though we don't know any real problem that it causes. Then, > nilfs2: use BIT() macro replaces "(1 << b)" style bit shifts with the generic BIT() macro for simplicity. Finally, > nilfs2: move ioctl interface and disk layout to uapi separately moves nilfs2_fs.h header, which is currently stored in the "include/linux" directory, to the uapi directory, splitting the file into two headers "nilfs2_api.h" and "nilfs2_ondisk.h"; the former separates ioctl related definitions and the latter collects up on-disk structures. Thanks, Ryusuke Konishi -- Documentation/filesystems/nilfs2.txt | 3 +- Documentation/ioctl/ioctl-number.txt | 2 +- MAINTAINERS | 3 +- fs/nilfs2/bmap.h | 2 +- fs/nilfs2/btnode.c | 4 +- fs/nilfs2/btree.h| 2 +- fs/nilfs2/cpfile.c | 1 - fs/nilfs2/cpfile.h | 3 +- fs/nilfs2/dat.h | 1 + fs/nilfs2/dir.c | 22 + fs/nilfs2/direct.h | 10 - fs/nilfs2/ifile.h| 1 - fs/nilfs2/inode.c| 4 +- fs/nilfs2/ioctl.c| 1 - fs/nilfs2/nilfs.h| 18 +- fs/nilfs2/page.c | 26 +- fs/nilfs2/segment.c | 14 +- fs/nilfs2/segment.h | 1 - fs/nilfs2/sufile.c | 13 +- fs/nilfs2/sufile.h | 1 - fs/nilfs2/sysfs.c| 44 +- fs/nilfs2/the_nilfs.h| 7 +- include/linux/nilfs2_fs.h| 934 --- include/uapi/linux/nilfs2_api.h | 292 +++ include/uapi/linux/nilfs2_ondisk.h | 650 25 files changed, 1037 insertions(+), 1022 deletions(-) delete mode 100644 include/linux/nilfs2_fs.h create mode 100644 include/uapi/linux/nilfs2_api.h create mode 100644 include/uapi/linux/nilfs2_ondisk.h
[PATCH 0/3] nilfs2 additional updates
Hi Andrew, please add the following changes for the next merge window: Ryusuke Konishi (3): nilfs2: fix misuse of a semaphore in sysfs code nilfs2: use BIT() macro nilfs2: move ioctl interface and disk layout to uapi separately In this series, > nilfs2: fix misuse of a semaphore in sysfs code corrects, as its name suggests, wrong use of a semaphore, though we don't know any real problem that it causes. Then, > nilfs2: use BIT() macro replaces "(1 << b)" style bit shifts with the generic BIT() macro for simplicity. Finally, > nilfs2: move ioctl interface and disk layout to uapi separately moves nilfs2_fs.h header, which is currently stored in the "include/linux" directory, to the uapi directory, splitting the file into two headers "nilfs2_api.h" and "nilfs2_ondisk.h"; the former separates ioctl related definitions and the latter collects up on-disk structures. Thanks, Ryusuke Konishi -- Documentation/filesystems/nilfs2.txt | 3 +- Documentation/ioctl/ioctl-number.txt | 2 +- MAINTAINERS | 3 +- fs/nilfs2/bmap.h | 2 +- fs/nilfs2/btnode.c | 4 +- fs/nilfs2/btree.h| 2 +- fs/nilfs2/cpfile.c | 1 - fs/nilfs2/cpfile.h | 3 +- fs/nilfs2/dat.h | 1 + fs/nilfs2/dir.c | 22 + fs/nilfs2/direct.h | 10 - fs/nilfs2/ifile.h| 1 - fs/nilfs2/inode.c| 4 +- fs/nilfs2/ioctl.c| 1 - fs/nilfs2/nilfs.h| 18 +- fs/nilfs2/page.c | 26 +- fs/nilfs2/segment.c | 14 +- fs/nilfs2/segment.h | 1 - fs/nilfs2/sufile.c | 13 +- fs/nilfs2/sufile.h | 1 - fs/nilfs2/sysfs.c| 44 +- fs/nilfs2/the_nilfs.h| 7 +- include/linux/nilfs2_fs.h| 934 --- include/uapi/linux/nilfs2_api.h | 292 +++ include/uapi/linux/nilfs2_ondisk.h | 650 25 files changed, 1037 insertions(+), 1022 deletions(-) delete mode 100644 include/linux/nilfs2_fs.h create mode 100644 include/uapi/linux/nilfs2_api.h create mode 100644 include/uapi/linux/nilfs2_ondisk.h
[PATCH 2/3] nilfs2: use BIT() macro
Replace bit shifts by BIT macro for clarity. Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/btnode.c | 4 ++-- fs/nilfs2/inode.c | 4 ++-- fs/nilfs2/nilfs.h | 15 +++ fs/nilfs2/page.c| 26 +- fs/nilfs2/segment.c | 14 +++--- fs/nilfs2/sufile.c | 12 ++-- 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index 0576033..7641cc8 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -41,7 +41,7 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr) struct inode *inode = NILFS_BTNC_I(btnc); struct buffer_head *bh; - bh = nilfs_grab_buffer(inode, btnc, blocknr, 1 << BH_NILFS_Node); + bh = nilfs_grab_buffer(inode, btnc, blocknr, BIT(BH_NILFS_Node)); if (unlikely(!bh)) return NULL; @@ -70,7 +70,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, struct page *page; int err; - bh = nilfs_grab_buffer(inode, btnc, blocknr, 1 << BH_NILFS_Node); + bh = nilfs_grab_buffer(inode, btnc, blocknr, BIT(BH_NILFS_Node)); if (unlikely(!bh)) return -ENOMEM; diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index b286b35..af04f55 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -356,7 +356,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode) root = NILFS_I(dir)->i_root; ii = NILFS_I(inode); - ii->i_state = 1 << NILFS_I_NEW; + ii->i_state = BIT(NILFS_I_NEW); ii->i_root = root; err = nilfs_ifile_create_inode(root->ifile, , >i_bh); @@ -555,7 +555,7 @@ static int nilfs_iget_set(struct inode *inode, void *opaque) inode->i_ino = args->ino; if (args->for_gc) { - NILFS_I(inode)->i_state = 1 << NILFS_I_GCINODE; + NILFS_I(inode)->i_state = BIT(NILFS_I_GCINODE); NILFS_I(inode)->i_cno = args->cno; NILFS_I(inode)->i_root = NULL; } else { diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index b7064fae..c6b6960 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h @@ -119,20 +119,19 @@ enum { /* * Macros to check inode numbers */ -#define NILFS_MDT_INO_BITS \ - ((unsigned int)(1 << NILFS_DAT_INO | 1 << NILFS_CPFILE_INO |\ - 1 << NILFS_SUFILE_INO | 1 << NILFS_IFILE_INO | \ - 1 << NILFS_ATIME_INO | 1 << NILFS_SKETCH_INO)) +#define NILFS_MDT_INO_BITS \ + (BIT(NILFS_DAT_INO) | BIT(NILFS_CPFILE_INO) | \ +BIT(NILFS_SUFILE_INO) | BIT(NILFS_IFILE_INO) | \ +BIT(NILFS_ATIME_INO) | BIT(NILFS_SKETCH_INO)) -#define NILFS_SYS_INO_BITS \ - ((unsigned int)(1 << NILFS_ROOT_INO) | NILFS_MDT_INO_BITS) +#define NILFS_SYS_INO_BITS (BIT(NILFS_ROOT_INO) | NILFS_MDT_INO_BITS) #define NILFS_FIRST_INO(sb) (((struct the_nilfs *)sb->s_fs_info)->ns_first_ino) #define NILFS_MDT_INODE(sb, ino) \ - ((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & (1 << (ino + ((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & BIT(ino))) #define NILFS_VALID_INODE(sb, ino) \ - ((ino) >= NILFS_FIRST_INO(sb) || (NILFS_SYS_INO_BITS & (1 << (ino + ((ino) >= NILFS_FIRST_INO(sb) || (NILFS_SYS_INO_BITS & BIT(ino))) /** * struct nilfs_transaction_info: context information for synchronization diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index eaccf12..f11a3ad 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -30,9 +30,9 @@ #include "mdt.h" -#define NILFS_BUFFER_INHERENT_BITS \ - ((1UL << BH_Uptodate) | (1UL << BH_Mapped) | (1UL << BH_NILFS_Node) | \ -(1UL << BH_NILFS_Volatile) | (1UL << BH_NILFS_Checked)) +#define NILFS_BUFFER_INHERENT_BITS \ + (BIT(BH_Uptodate) | BIT(BH_Mapped) | BIT(BH_NILFS_Node) | \ +BIT(BH_NILFS_Volatile) | BIT(BH_NILFS_Checked)) static struct buffer_head * __nilfs_get_page_block(struct page *page, unsigned long block, pgoff_t index, @@ -85,9 +85,9 @@ void nilfs_forget_buffer(struct buffer_head *bh) { struct page *page = bh->b_page; const unsigned long clear_bits = - (1 << BH_Uptodate | 1 << BH_Dirty | 1 << BH_Mapped | -1 << BH_Async_Write | 1 << BH_NILFS_Volatile | -1 << BH_NILFS_Checked | 1 << BH_NILFS_Redirected); + (BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) | +BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) | +BIT(BH_NILFS_C
[PATCH 3/3] nilfs2: move ioctl interface and disk layout to uapi separately
The header file "include/linux/nilfs2_fs.h" is composed of parts for ioctl and disk format, and both are intended to be shared with user space programs. This moves them to the uapi directory "include/uapi/linux" splitting the file to "nilfs2_api.h" and "nilfs2_ondisk.h". The following minor changes are accompanied by this migration: - nilfs_direct_node struct in nilfs2/direct.h is converged to nilfs2_ondisk.h because it's an on-disk structure. - inline functions nilfs_rec_len_from_disk() and nilfs_rec_len_to_disk() are moved to nilfs2/dir.c. Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- Documentation/filesystems/nilfs2.txt | 3 +- Documentation/ioctl/ioctl-number.txt | 2 +- MAINTAINERS | 3 +- fs/nilfs2/bmap.h | 2 +- fs/nilfs2/btree.h| 2 +- fs/nilfs2/cpfile.c | 1 - fs/nilfs2/cpfile.h | 3 +- fs/nilfs2/dat.h | 1 + fs/nilfs2/dir.c | 22 + fs/nilfs2/direct.h | 10 - fs/nilfs2/ifile.h| 1 - fs/nilfs2/ioctl.c| 1 - fs/nilfs2/nilfs.h| 3 +- fs/nilfs2/segment.h | 1 - fs/nilfs2/sufile.c | 1 - fs/nilfs2/sufile.h | 1 - include/linux/nilfs2_fs.h| 934 --- include/uapi/linux/nilfs2_api.h | 292 +++ include/uapi/linux/nilfs2_ondisk.h | 650 19 files changed, 976 insertions(+), 957 deletions(-) delete mode 100644 include/linux/nilfs2_fs.h create mode 100644 include/uapi/linux/nilfs2_api.h create mode 100644 include/uapi/linux/nilfs2_ondisk.h diff --git a/Documentation/filesystems/nilfs2.txt b/Documentation/filesystems/nilfs2.txt index 5b21ef7..c0727dc 100644 --- a/Documentation/filesystems/nilfs2.txt +++ b/Documentation/filesystems/nilfs2.txt @@ -267,7 +267,8 @@ among NILFS2 files can be depicted as follows: `-- file (ino=yy) ( regular file, directory, or symlink ) -For detail on the format of each file, please see include/linux/nilfs2_fs.h. +For detail on the format of each file, please see nilfs2_ondisk.h +located at include/uapi/linux directory. There are no patents or other intellectual property that we protect with regard to the design of NILFS2. It is allowed to replicate the diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt index 9369d3b..26562a1 100644 --- a/Documentation/ioctl/ioctl-number.txt +++ b/Documentation/ioctl/ioctl-number.txt @@ -248,7 +248,7 @@ Code Seq#(hex) Include FileComments 'm'00 drivers/scsi/megaraid/megaraid_ioctl.h conflict! 'm'00-1F net/irda/irmod.hconflict! 'n'00-7F linux/ncp_fs.h and fs/ncpfs/ioctl.c -'n'80-8F linux/nilfs2_fs.h NILFS2 +'n'80-8F uapi/linux/nilfs2_api.h NILFS2 'n'E0-FF linux/matroxfb.hmatroxfb 'o'00-1F fs/ocfs2/ocfs2_fs.h OCFS2 'o' 00-03 mtd/ubi-user.h conflict! (OCFS2 and UBI overlaps) diff --git a/MAINTAINERS b/MAINTAINERS index 16700e4..8a94fba 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8065,8 +8065,9 @@ T:git git://github.com/konis/nilfs2.git S: Supported F: Documentation/filesystems/nilfs2.txt F: fs/nilfs2/ -F: include/linux/nilfs2_fs.h F: include/trace/events/nilfs2.h +F: include/uapi/linux/nilfs2_api.h +F: include/uapi/linux/nilfs2_ondisk.h NINJA SCSI-3 / NINJA SCSI-32Bi (16bit/CardBus) PCMCIA SCSI HOST ADAPTER DRIVER M: YOKOTA Hiroshi <yok...@netlab.is.tsukuba.ac.jp> diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h index b6a4c8f..2b6ffbe 100644 --- a/fs/nilfs2/bmap.h +++ b/fs/nilfs2/bmap.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include/* nilfs_binfo, nilfs_inode, etc */ #include "alloc.h" #include "dat.h" diff --git a/fs/nilfs2/btree.h b/fs/nilfs2/btree.h index df1a25f..2184e47 100644 --- a/fs/nilfs2/btree.h +++ b/fs/nilfs2/btree.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include/* nilfs_btree_node */ #include "btnode.h" #include "bmap.h" diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c index 19d9f4a..a15a160 100644 --- a/fs/nilfs2/cpfile.c +++ b/fs/nilfs2/cpfile.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "mdt.h" #include "cpfile.h" diff --git a/fs/nilfs2/cpfile.h b/fs/nilfs2/cpfile.h index 0249744..6eca972 100644 --- a/fs/nilfs2/cpfile.h +++ b/fs/nilfs2/cpfile.h @@ -21,7 +21,8 @@ #include #include -#include +#include /* nilfs_cpstat */ +#include/* nilfs_inode, nilfs_checkpoint */ int nilfs_cpfile_get_checkpoint(s
[PATCH 2/3] nilfs2: use BIT() macro
Replace bit shifts by BIT macro for clarity. Signed-off-by: Ryusuke Konishi --- fs/nilfs2/btnode.c | 4 ++-- fs/nilfs2/inode.c | 4 ++-- fs/nilfs2/nilfs.h | 15 +++ fs/nilfs2/page.c| 26 +- fs/nilfs2/segment.c | 14 +++--- fs/nilfs2/sufile.c | 12 ++-- 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index 0576033..7641cc8 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -41,7 +41,7 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr) struct inode *inode = NILFS_BTNC_I(btnc); struct buffer_head *bh; - bh = nilfs_grab_buffer(inode, btnc, blocknr, 1 << BH_NILFS_Node); + bh = nilfs_grab_buffer(inode, btnc, blocknr, BIT(BH_NILFS_Node)); if (unlikely(!bh)) return NULL; @@ -70,7 +70,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, struct page *page; int err; - bh = nilfs_grab_buffer(inode, btnc, blocknr, 1 << BH_NILFS_Node); + bh = nilfs_grab_buffer(inode, btnc, blocknr, BIT(BH_NILFS_Node)); if (unlikely(!bh)) return -ENOMEM; diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index b286b35..af04f55 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -356,7 +356,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode) root = NILFS_I(dir)->i_root; ii = NILFS_I(inode); - ii->i_state = 1 << NILFS_I_NEW; + ii->i_state = BIT(NILFS_I_NEW); ii->i_root = root; err = nilfs_ifile_create_inode(root->ifile, , >i_bh); @@ -555,7 +555,7 @@ static int nilfs_iget_set(struct inode *inode, void *opaque) inode->i_ino = args->ino; if (args->for_gc) { - NILFS_I(inode)->i_state = 1 << NILFS_I_GCINODE; + NILFS_I(inode)->i_state = BIT(NILFS_I_GCINODE); NILFS_I(inode)->i_cno = args->cno; NILFS_I(inode)->i_root = NULL; } else { diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index b7064fae..c6b6960 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h @@ -119,20 +119,19 @@ enum { /* * Macros to check inode numbers */ -#define NILFS_MDT_INO_BITS \ - ((unsigned int)(1 << NILFS_DAT_INO | 1 << NILFS_CPFILE_INO |\ - 1 << NILFS_SUFILE_INO | 1 << NILFS_IFILE_INO | \ - 1 << NILFS_ATIME_INO | 1 << NILFS_SKETCH_INO)) +#define NILFS_MDT_INO_BITS \ + (BIT(NILFS_DAT_INO) | BIT(NILFS_CPFILE_INO) | \ +BIT(NILFS_SUFILE_INO) | BIT(NILFS_IFILE_INO) | \ +BIT(NILFS_ATIME_INO) | BIT(NILFS_SKETCH_INO)) -#define NILFS_SYS_INO_BITS \ - ((unsigned int)(1 << NILFS_ROOT_INO) | NILFS_MDT_INO_BITS) +#define NILFS_SYS_INO_BITS (BIT(NILFS_ROOT_INO) | NILFS_MDT_INO_BITS) #define NILFS_FIRST_INO(sb) (((struct the_nilfs *)sb->s_fs_info)->ns_first_ino) #define NILFS_MDT_INODE(sb, ino) \ - ((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & (1 << (ino + ((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & BIT(ino))) #define NILFS_VALID_INODE(sb, ino) \ - ((ino) >= NILFS_FIRST_INO(sb) || (NILFS_SYS_INO_BITS & (1 << (ino + ((ino) >= NILFS_FIRST_INO(sb) || (NILFS_SYS_INO_BITS & BIT(ino))) /** * struct nilfs_transaction_info: context information for synchronization diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index eaccf12..f11a3ad 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -30,9 +30,9 @@ #include "mdt.h" -#define NILFS_BUFFER_INHERENT_BITS \ - ((1UL << BH_Uptodate) | (1UL << BH_Mapped) | (1UL << BH_NILFS_Node) | \ -(1UL << BH_NILFS_Volatile) | (1UL << BH_NILFS_Checked)) +#define NILFS_BUFFER_INHERENT_BITS \ + (BIT(BH_Uptodate) | BIT(BH_Mapped) | BIT(BH_NILFS_Node) | \ +BIT(BH_NILFS_Volatile) | BIT(BH_NILFS_Checked)) static struct buffer_head * __nilfs_get_page_block(struct page *page, unsigned long block, pgoff_t index, @@ -85,9 +85,9 @@ void nilfs_forget_buffer(struct buffer_head *bh) { struct page *page = bh->b_page; const unsigned long clear_bits = - (1 << BH_Uptodate | 1 << BH_Dirty | 1 << BH_Mapped | -1 << BH_Async_Write | 1 << BH_NILFS_Volatile | -1 << BH_NILFS_Checked | 1 << BH_NILFS_Redirected); + (BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) | +BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) | +BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected));
[PATCH 3/3] nilfs2: move ioctl interface and disk layout to uapi separately
The header file "include/linux/nilfs2_fs.h" is composed of parts for ioctl and disk format, and both are intended to be shared with user space programs. This moves them to the uapi directory "include/uapi/linux" splitting the file to "nilfs2_api.h" and "nilfs2_ondisk.h". The following minor changes are accompanied by this migration: - nilfs_direct_node struct in nilfs2/direct.h is converged to nilfs2_ondisk.h because it's an on-disk structure. - inline functions nilfs_rec_len_from_disk() and nilfs_rec_len_to_disk() are moved to nilfs2/dir.c. Signed-off-by: Ryusuke Konishi --- Documentation/filesystems/nilfs2.txt | 3 +- Documentation/ioctl/ioctl-number.txt | 2 +- MAINTAINERS | 3 +- fs/nilfs2/bmap.h | 2 +- fs/nilfs2/btree.h| 2 +- fs/nilfs2/cpfile.c | 1 - fs/nilfs2/cpfile.h | 3 +- fs/nilfs2/dat.h | 1 + fs/nilfs2/dir.c | 22 + fs/nilfs2/direct.h | 10 - fs/nilfs2/ifile.h| 1 - fs/nilfs2/ioctl.c| 1 - fs/nilfs2/nilfs.h| 3 +- fs/nilfs2/segment.h | 1 - fs/nilfs2/sufile.c | 1 - fs/nilfs2/sufile.h | 1 - include/linux/nilfs2_fs.h| 934 --- include/uapi/linux/nilfs2_api.h | 292 +++ include/uapi/linux/nilfs2_ondisk.h | 650 19 files changed, 976 insertions(+), 957 deletions(-) delete mode 100644 include/linux/nilfs2_fs.h create mode 100644 include/uapi/linux/nilfs2_api.h create mode 100644 include/uapi/linux/nilfs2_ondisk.h diff --git a/Documentation/filesystems/nilfs2.txt b/Documentation/filesystems/nilfs2.txt index 5b21ef7..c0727dc 100644 --- a/Documentation/filesystems/nilfs2.txt +++ b/Documentation/filesystems/nilfs2.txt @@ -267,7 +267,8 @@ among NILFS2 files can be depicted as follows: `-- file (ino=yy) ( regular file, directory, or symlink ) -For detail on the format of each file, please see include/linux/nilfs2_fs.h. +For detail on the format of each file, please see nilfs2_ondisk.h +located at include/uapi/linux directory. There are no patents or other intellectual property that we protect with regard to the design of NILFS2. It is allowed to replicate the diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt index 9369d3b..26562a1 100644 --- a/Documentation/ioctl/ioctl-number.txt +++ b/Documentation/ioctl/ioctl-number.txt @@ -248,7 +248,7 @@ Code Seq#(hex) Include FileComments 'm'00 drivers/scsi/megaraid/megaraid_ioctl.h conflict! 'm'00-1F net/irda/irmod.hconflict! 'n'00-7F linux/ncp_fs.h and fs/ncpfs/ioctl.c -'n'80-8F linux/nilfs2_fs.h NILFS2 +'n'80-8F uapi/linux/nilfs2_api.h NILFS2 'n'E0-FF linux/matroxfb.hmatroxfb 'o'00-1F fs/ocfs2/ocfs2_fs.h OCFS2 'o' 00-03 mtd/ubi-user.h conflict! (OCFS2 and UBI overlaps) diff --git a/MAINTAINERS b/MAINTAINERS index 16700e4..8a94fba 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8065,8 +8065,9 @@ T:git git://github.com/konis/nilfs2.git S: Supported F: Documentation/filesystems/nilfs2.txt F: fs/nilfs2/ -F: include/linux/nilfs2_fs.h F: include/trace/events/nilfs2.h +F: include/uapi/linux/nilfs2_api.h +F: include/uapi/linux/nilfs2_ondisk.h NINJA SCSI-3 / NINJA SCSI-32Bi (16bit/CardBus) PCMCIA SCSI HOST ADAPTER DRIVER M: YOKOTA Hiroshi diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h index b6a4c8f..2b6ffbe 100644 --- a/fs/nilfs2/bmap.h +++ b/fs/nilfs2/bmap.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include/* nilfs_binfo, nilfs_inode, etc */ #include "alloc.h" #include "dat.h" diff --git a/fs/nilfs2/btree.h b/fs/nilfs2/btree.h index df1a25f..2184e47 100644 --- a/fs/nilfs2/btree.h +++ b/fs/nilfs2/btree.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include/* nilfs_btree_node */ #include "btnode.h" #include "bmap.h" diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c index 19d9f4a..a15a160 100644 --- a/fs/nilfs2/cpfile.c +++ b/fs/nilfs2/cpfile.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "mdt.h" #include "cpfile.h" diff --git a/fs/nilfs2/cpfile.h b/fs/nilfs2/cpfile.h index 0249744..6eca972 100644 --- a/fs/nilfs2/cpfile.h +++ b/fs/nilfs2/cpfile.h @@ -21,7 +21,8 @@ #include #include -#include +#include /* nilfs_cpstat */ +#include/* nilfs_inode, nilfs_checkpoint */ int nilfs_cpfile_get_checkpoint(struct inode *, __u64, int, diff --git a/fs/nilfs2/dat.h b/fs/nilfs2/dat.h i
[PATCH 1/3] nilfs2: fix misuse of a semaphore in sysfs code
Variables ns_seg_seq, ns_segnum, ns_nextnum, ns_pseg_offset, ns_cno, ns_ctime, ns_nongc_ctime, and ns_ndirtyblks, are protected by ns_segctor_sem, but ns_sem is wrongly used by the nilfs sysfs code when reading these variables. This fixes the misuse and clarifies which semaphore protects them in the comment of the_nilfs struct. Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/sysfs.c | 44 ++-- fs/nilfs2/the_nilfs.h | 7 ++- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c index 8e57bb9..490303e 100644 --- a/fs/nilfs2/sysfs.c +++ b/fs/nilfs2/sysfs.c @@ -326,9 +326,9 @@ nilfs_checkpoints_next_checkpoint_show(struct nilfs_checkpoints_attr *attr, { __u64 cno; - down_read(>ns_sem); + down_read(>ns_segctor_sem); cno = nilfs->ns_cno; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", cno); } @@ -511,9 +511,9 @@ nilfs_segctor_current_seg_sequence_show(struct nilfs_segctor_attr *attr, { u64 seg_seq; - down_read(>ns_sem); + down_read(>ns_segctor_sem); seg_seq = nilfs->ns_seg_seq; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", seg_seq); } @@ -525,9 +525,9 @@ nilfs_segctor_current_last_full_seg_show(struct nilfs_segctor_attr *attr, { __u64 segnum; - down_read(>ns_sem); + down_read(>ns_segctor_sem); segnum = nilfs->ns_segnum; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", segnum); } @@ -539,9 +539,9 @@ nilfs_segctor_next_full_seg_show(struct nilfs_segctor_attr *attr, { __u64 nextnum; - down_read(>ns_sem); + down_read(>ns_segctor_sem); nextnum = nilfs->ns_nextnum; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", nextnum); } @@ -553,9 +553,9 @@ nilfs_segctor_next_pseg_offset_show(struct nilfs_segctor_attr *attr, { unsigned long pseg_offset; - down_read(>ns_sem); + down_read(>ns_segctor_sem); pseg_offset = nilfs->ns_pseg_offset; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%lu\n", pseg_offset); } @@ -567,9 +567,9 @@ nilfs_segctor_next_checkpoint_show(struct nilfs_segctor_attr *attr, { __u64 cno; - down_read(>ns_sem); + down_read(>ns_segctor_sem); cno = nilfs->ns_cno; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", cno); } @@ -581,9 +581,9 @@ nilfs_segctor_last_seg_write_time_show(struct nilfs_segctor_attr *attr, { time_t ctime; - down_read(>ns_sem); + down_read(>ns_segctor_sem); ctime = nilfs->ns_ctime; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return NILFS_SHOW_TIME(ctime, buf); } @@ -595,9 +595,9 @@ nilfs_segctor_last_seg_write_time_secs_show(struct nilfs_segctor_attr *attr, { time_t ctime; - down_read(>ns_sem); + down_read(>ns_segctor_sem); ctime = nilfs->ns_ctime; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", (unsigned long long)ctime); } @@ -609,9 +609,9 @@ nilfs_segctor_last_nongc_write_time_show(struct nilfs_segctor_attr *attr, { time_t nongc_ctime; - down_read(>ns_sem); + down_read(>ns_segctor_sem); nongc_ctime = nilfs->ns_nongc_ctime; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return NILFS_SHOW_TIME(nongc_ctime, buf); } @@ -623,9 +623,9 @@ nilfs_segctor_last_nongc_write_time_secs_show(struct nilfs_segctor_attr *attr, { time_t nongc_ctime; - down_read(>ns_sem); + down_read(>ns_segctor_sem); nongc_ctime = nilfs->ns_nongc_ctime; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", (unsigned long long)nongc_ctime); @@ -638,9 +638,9 @@ nilfs_segctor_dirty_data_blocks_count_show(struct nilfs_segctor_attr *attr, { u32 ndirtyblks; - down_read(>ns_sem); + down_read(>ns_segctor_sem); ndirtyblks = atomic_read(>ns_ndirtyblks); - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%u\n", ndirtyblks); } diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index 79d1421..b305c6f 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h @@ -122,11 +122,8
[PATCH 1/3] nilfs2: fix misuse of a semaphore in sysfs code
Variables ns_seg_seq, ns_segnum, ns_nextnum, ns_pseg_offset, ns_cno, ns_ctime, ns_nongc_ctime, and ns_ndirtyblks, are protected by ns_segctor_sem, but ns_sem is wrongly used by the nilfs sysfs code when reading these variables. This fixes the misuse and clarifies which semaphore protects them in the comment of the_nilfs struct. Signed-off-by: Ryusuke Konishi --- fs/nilfs2/sysfs.c | 44 ++-- fs/nilfs2/the_nilfs.h | 7 ++- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c index 8e57bb9..490303e 100644 --- a/fs/nilfs2/sysfs.c +++ b/fs/nilfs2/sysfs.c @@ -326,9 +326,9 @@ nilfs_checkpoints_next_checkpoint_show(struct nilfs_checkpoints_attr *attr, { __u64 cno; - down_read(>ns_sem); + down_read(>ns_segctor_sem); cno = nilfs->ns_cno; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", cno); } @@ -511,9 +511,9 @@ nilfs_segctor_current_seg_sequence_show(struct nilfs_segctor_attr *attr, { u64 seg_seq; - down_read(>ns_sem); + down_read(>ns_segctor_sem); seg_seq = nilfs->ns_seg_seq; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", seg_seq); } @@ -525,9 +525,9 @@ nilfs_segctor_current_last_full_seg_show(struct nilfs_segctor_attr *attr, { __u64 segnum; - down_read(>ns_sem); + down_read(>ns_segctor_sem); segnum = nilfs->ns_segnum; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", segnum); } @@ -539,9 +539,9 @@ nilfs_segctor_next_full_seg_show(struct nilfs_segctor_attr *attr, { __u64 nextnum; - down_read(>ns_sem); + down_read(>ns_segctor_sem); nextnum = nilfs->ns_nextnum; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", nextnum); } @@ -553,9 +553,9 @@ nilfs_segctor_next_pseg_offset_show(struct nilfs_segctor_attr *attr, { unsigned long pseg_offset; - down_read(>ns_sem); + down_read(>ns_segctor_sem); pseg_offset = nilfs->ns_pseg_offset; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%lu\n", pseg_offset); } @@ -567,9 +567,9 @@ nilfs_segctor_next_checkpoint_show(struct nilfs_segctor_attr *attr, { __u64 cno; - down_read(>ns_sem); + down_read(>ns_segctor_sem); cno = nilfs->ns_cno; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", cno); } @@ -581,9 +581,9 @@ nilfs_segctor_last_seg_write_time_show(struct nilfs_segctor_attr *attr, { time_t ctime; - down_read(>ns_sem); + down_read(>ns_segctor_sem); ctime = nilfs->ns_ctime; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return NILFS_SHOW_TIME(ctime, buf); } @@ -595,9 +595,9 @@ nilfs_segctor_last_seg_write_time_secs_show(struct nilfs_segctor_attr *attr, { time_t ctime; - down_read(>ns_sem); + down_read(>ns_segctor_sem); ctime = nilfs->ns_ctime; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", (unsigned long long)ctime); } @@ -609,9 +609,9 @@ nilfs_segctor_last_nongc_write_time_show(struct nilfs_segctor_attr *attr, { time_t nongc_ctime; - down_read(>ns_sem); + down_read(>ns_segctor_sem); nongc_ctime = nilfs->ns_nongc_ctime; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return NILFS_SHOW_TIME(nongc_ctime, buf); } @@ -623,9 +623,9 @@ nilfs_segctor_last_nongc_write_time_secs_show(struct nilfs_segctor_attr *attr, { time_t nongc_ctime; - down_read(>ns_sem); + down_read(>ns_segctor_sem); nongc_ctime = nilfs->ns_nongc_ctime; - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%llu\n", (unsigned long long)nongc_ctime); @@ -638,9 +638,9 @@ nilfs_segctor_dirty_data_blocks_count_show(struct nilfs_segctor_attr *attr, { u32 ndirtyblks; - down_read(>ns_sem); + down_read(>ns_segctor_sem); ndirtyblks = atomic_read(>ns_ndirtyblks); - up_read(>ns_sem); + up_read(>ns_segctor_sem); return snprintf(buf, PAGE_SIZE, "%u\n", ndirtyblks); } diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index 79d1421..b305c6f 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h @@ -122,11 +122,8 @@ struct the_nilfs { unsign
[PATCH 8/8] nilfs2: refactor parser of snapshot mount option
Move parser of snapshot mount option to a separate function nilfs_parse_snapshot_option(), replace simple_strtoull() with kstrtoull() to avoid checkpatch.pl warning "WARNING: simple_strtoull is obsolete, use kstrtoull instead", and refine the error message of the parser. Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/super.c | 53 +++-- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 33ba6f7..c95d369 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -1205,6 +1205,38 @@ struct nilfs_super_data { int flags; }; +static int nilfs_parse_snapshot_option(const char *option, + const substring_t *arg, + struct nilfs_super_data *sd) +{ + unsigned long long val; + const char *msg = NULL; + int err; + + if (!(sd->flags & MS_RDONLY)) { + msg = "read-only option is not specified"; + goto parse_error; + } + + err = kstrtoull(arg->from, 0, ); + if (err) { + if (err == -ERANGE) + msg = "too large checkpoint number"; + else + msg = "malformed argument"; + goto parse_error; + } else if (val == 0) { + msg = "invalid checkpoint number 0"; + goto parse_error; + } + sd->cno = val; + return 0; + +parse_error: + nilfs_msg(NULL, KERN_ERR, "invalid option \"%s\": %s", option, msg); + return 1; +} + /** * nilfs_identify - pre-read mount options needed to identify mount instance * @data: mount options @@ -1221,24 +1253,9 @@ static int nilfs_identify(char *data, struct nilfs_super_data *sd) p = strsep(, ","); if (p != NULL && *p) { token = match_token(p, tokens, args); - if (token == Opt_snapshot) { - if (!(sd->flags & MS_RDONLY)) { - ret++; - } else { - sd->cno = simple_strtoull(args[0].from, - NULL, 0); - /* -* No need to see the end pointer; -* match_token() has done syntax -* checking. -*/ - if (sd->cno == 0) - ret++; - } - } - if (ret) - nilfs_msg(NULL, KERN_ERR, - "invalid mount option: %s", p); + if (token == Opt_snapshot) + ret = nilfs_parse_snapshot_option(p, [0], + sd); } if (!options) break; -- 1.8.3.1
[PATCH 8/8] nilfs2: refactor parser of snapshot mount option
Move parser of snapshot mount option to a separate function nilfs_parse_snapshot_option(), replace simple_strtoull() with kstrtoull() to avoid checkpatch.pl warning "WARNING: simple_strtoull is obsolete, use kstrtoull instead", and refine the error message of the parser. Signed-off-by: Ryusuke Konishi --- fs/nilfs2/super.c | 53 +++-- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 33ba6f7..c95d369 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -1205,6 +1205,38 @@ struct nilfs_super_data { int flags; }; +static int nilfs_parse_snapshot_option(const char *option, + const substring_t *arg, + struct nilfs_super_data *sd) +{ + unsigned long long val; + const char *msg = NULL; + int err; + + if (!(sd->flags & MS_RDONLY)) { + msg = "read-only option is not specified"; + goto parse_error; + } + + err = kstrtoull(arg->from, 0, ); + if (err) { + if (err == -ERANGE) + msg = "too large checkpoint number"; + else + msg = "malformed argument"; + goto parse_error; + } else if (val == 0) { + msg = "invalid checkpoint number 0"; + goto parse_error; + } + sd->cno = val; + return 0; + +parse_error: + nilfs_msg(NULL, KERN_ERR, "invalid option \"%s\": %s", option, msg); + return 1; +} + /** * nilfs_identify - pre-read mount options needed to identify mount instance * @data: mount options @@ -1221,24 +1253,9 @@ static int nilfs_identify(char *data, struct nilfs_super_data *sd) p = strsep(, ","); if (p != NULL && *p) { token = match_token(p, tokens, args); - if (token == Opt_snapshot) { - if (!(sd->flags & MS_RDONLY)) { - ret++; - } else { - sd->cno = simple_strtoull(args[0].from, - NULL, 0); - /* -* No need to see the end pointer; -* match_token() has done syntax -* checking. -*/ - if (sd->cno == 0) - ret++; - } - } - if (ret) - nilfs_msg(NULL, KERN_ERR, - "invalid mount option: %s", p); + if (token == Opt_snapshot) + ret = nilfs_parse_snapshot_option(p, [0], + sd); } if (!options) break; -- 1.8.3.1
[PATCH 1/8] nilfs2: hide function name argument from nilfs_error()
Simplify nilfs_error(), an output function used to report critical issues in file system. This renames the original nilfs_error() function to __nilfs_error() and redefines it as a macro to hide its function name argument within the macro. Every call site of nilfs_error() is changed to strip __func__ argument except nilfs_bmap_convert_error(); nilfs_bmap_convert_error() directly calls __nilfs_error() because it inherits caller's function name. Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/bmap.c | 4 ++-- fs/nilfs2/dir.c | 38 +- fs/nilfs2/ifile.c | 3 +-- fs/nilfs2/nilfs.h | 20 +++- fs/nilfs2/super.c | 22 -- 5 files changed, 51 insertions(+), 36 deletions(-) diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index f2a7877..01fb183 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -41,8 +41,8 @@ static int nilfs_bmap_convert_error(struct nilfs_bmap *bmap, struct inode *inode = bmap->b_inode; if (err == -EINVAL) { - nilfs_error(inode->i_sb, fname, - "broken bmap (inode number=%lu)", inode->i_ino); + __nilfs_error(inode->i_sb, fname, + "broken bmap (inode number=%lu)", inode->i_ino); err = -EIO; } return err; diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index e506f4f..746956d 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -140,10 +140,9 @@ out: /* Too bad, we had an error */ Ebadsize: - nilfs_error(sb, "nilfs_check_page", + nilfs_error(sb, "size of directory #%lu is not a multiple of chunk size", - dir->i_ino - ); + dir->i_ino); goto fail; Eshort: error = "rec_len is smaller than minimal"; @@ -157,19 +156,18 @@ Enamelen: Espan: error = "directory entry across blocks"; bad_entry: - nilfs_error(sb, "nilfs_check_page", "bad entry in directory #%lu: %s - " - "offset=%lu, inode=%lu, rec_len=%d, name_len=%d", - dir->i_ino, error, (page->index<<PAGE_SHIFT)+offs, - (unsigned long) le64_to_cpu(p->inode), + nilfs_error(sb, + "bad entry in directory #%lu: %s - offset=%lu, inode=%lu, rec_len=%d, name_len=%d", + dir->i_ino, error, (page->index << PAGE_SHIFT) + offs, + (unsigned long)le64_to_cpu(p->inode), rec_len, p->name_len); goto fail; Eend: p = (struct nilfs_dir_entry *)(kaddr + offs); - nilfs_error(sb, "nilfs_check_page", - "entry in directory #%lu spans the page boundary" - "offset=%lu, inode=%lu", - dir->i_ino, (page->index<<PAGE_SHIFT)+offs, - (unsigned long) le64_to_cpu(p->inode)); + nilfs_error(sb, + "entry in directory #%lu spans the page boundary offset=%lu, inode=%lu", + dir->i_ino, (page->index << PAGE_SHIFT) + offs, + (unsigned long)le64_to_cpu(p->inode)); fail: SetPageError(page); return false; @@ -267,8 +265,7 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) struct page *page = nilfs_get_page(inode, n); if (IS_ERR(page)) { - nilfs_error(sb, __func__, "bad page in #%lu", - inode->i_ino); + nilfs_error(sb, "bad page in #%lu", inode->i_ino); ctx->pos += PAGE_SIZE - offset; return -EIO; } @@ -278,8 +275,7 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) NILFS_DIR_REC_LEN(1); for ( ; (char *)de <= limit; de = nilfs_next_entry(de)) { if (de->rec_len == 0) { - nilfs_error(sb, __func__, - "zero-length directory entry"); + nilfs_error(sb, "zero-length directory entry"); nilfs_put_page(page); return -EIO; } @@ -345,7 +341,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, kaddr += nilfs_last_byte(dir, n) - reclen; while ((char *) de <= kaddr) { if (de->rec_len == 0) { - nilfs_error(dir->i_sb, __func__, +
[PATCH 1/8] nilfs2: hide function name argument from nilfs_error()
Simplify nilfs_error(), an output function used to report critical issues in file system. This renames the original nilfs_error() function to __nilfs_error() and redefines it as a macro to hide its function name argument within the macro. Every call site of nilfs_error() is changed to strip __func__ argument except nilfs_bmap_convert_error(); nilfs_bmap_convert_error() directly calls __nilfs_error() because it inherits caller's function name. Signed-off-by: Ryusuke Konishi --- fs/nilfs2/bmap.c | 4 ++-- fs/nilfs2/dir.c | 38 +- fs/nilfs2/ifile.c | 3 +-- fs/nilfs2/nilfs.h | 20 +++- fs/nilfs2/super.c | 22 -- 5 files changed, 51 insertions(+), 36 deletions(-) diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index f2a7877..01fb183 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -41,8 +41,8 @@ static int nilfs_bmap_convert_error(struct nilfs_bmap *bmap, struct inode *inode = bmap->b_inode; if (err == -EINVAL) { - nilfs_error(inode->i_sb, fname, - "broken bmap (inode number=%lu)", inode->i_ino); + __nilfs_error(inode->i_sb, fname, + "broken bmap (inode number=%lu)", inode->i_ino); err = -EIO; } return err; diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index e506f4f..746956d 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -140,10 +140,9 @@ out: /* Too bad, we had an error */ Ebadsize: - nilfs_error(sb, "nilfs_check_page", + nilfs_error(sb, "size of directory #%lu is not a multiple of chunk size", - dir->i_ino - ); + dir->i_ino); goto fail; Eshort: error = "rec_len is smaller than minimal"; @@ -157,19 +156,18 @@ Enamelen: Espan: error = "directory entry across blocks"; bad_entry: - nilfs_error(sb, "nilfs_check_page", "bad entry in directory #%lu: %s - " - "offset=%lu, inode=%lu, rec_len=%d, name_len=%d", - dir->i_ino, error, (page->index<inode), + nilfs_error(sb, + "bad entry in directory #%lu: %s - offset=%lu, inode=%lu, rec_len=%d, name_len=%d", + dir->i_ino, error, (page->index << PAGE_SHIFT) + offs, + (unsigned long)le64_to_cpu(p->inode), rec_len, p->name_len); goto fail; Eend: p = (struct nilfs_dir_entry *)(kaddr + offs); - nilfs_error(sb, "nilfs_check_page", - "entry in directory #%lu spans the page boundary" - "offset=%lu, inode=%lu", - dir->i_ino, (page->index<inode)); + nilfs_error(sb, + "entry in directory #%lu spans the page boundary offset=%lu, inode=%lu", + dir->i_ino, (page->index << PAGE_SHIFT) + offs, + (unsigned long)le64_to_cpu(p->inode)); fail: SetPageError(page); return false; @@ -267,8 +265,7 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) struct page *page = nilfs_get_page(inode, n); if (IS_ERR(page)) { - nilfs_error(sb, __func__, "bad page in #%lu", - inode->i_ino); + nilfs_error(sb, "bad page in #%lu", inode->i_ino); ctx->pos += PAGE_SIZE - offset; return -EIO; } @@ -278,8 +275,7 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) NILFS_DIR_REC_LEN(1); for ( ; (char *)de <= limit; de = nilfs_next_entry(de)) { if (de->rec_len == 0) { - nilfs_error(sb, __func__, - "zero-length directory entry"); + nilfs_error(sb, "zero-length directory entry"); nilfs_put_page(page); return -EIO; } @@ -345,7 +341,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, kaddr += nilfs_last_byte(dir, n) - reclen; while ((char *) de <= kaddr) { if (de->rec_len == 0) { - nilfs_error(dir->i_sb, __func__, + nilfs_error(dir->i_sb, "zero-length directory entry"); nilfs_put_page(page);
[PATCH 3/8] nilfs2: embed a back pointer to super block instance in nilfs object
Insert a back pointer to super block instance in nilfs object so that functions of nilfs2 easily refer to the super block instance. This simplifies replacement of printk() in the successive change. Signed-off-by: Ryusuke Konishi <konishi.ryus...@lab.ntt.co.jp> --- fs/nilfs2/super.c | 2 +- fs/nilfs2/the_nilfs.c | 7 --- fs/nilfs2/the_nilfs.h | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 86e3c00..2d4d0be 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -1076,7 +1076,7 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent) __u64 cno; int err; - nilfs = alloc_nilfs(sb->s_bdev); + nilfs = alloc_nilfs(sb); if (!nilfs) return -ENOMEM; diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 809bd2d..dbead89 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c @@ -56,12 +56,12 @@ void nilfs_set_last_segment(struct the_nilfs *nilfs, /** * alloc_nilfs - allocate a nilfs object - * @bdev: block device to which the_nilfs is related + * @sb: super block instance * * Return Value: On success, pointer to the_nilfs is returned. * On error, NULL is returned. */ -struct the_nilfs *alloc_nilfs(struct block_device *bdev) +struct the_nilfs *alloc_nilfs(struct super_block *sb) { struct the_nilfs *nilfs; @@ -69,7 +69,8 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev) if (!nilfs) return NULL; - nilfs->ns_bdev = bdev; + nilfs->ns_sb = sb; + nilfs->ns_bdev = sb->s_bdev; atomic_set(>ns_ndirtyblks, 0); init_rwsem(>ns_sem); mutex_init(>ns_snapshot_mount_mutex); diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index 79369fd..79d1421 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h @@ -43,6 +43,7 @@ enum { * struct the_nilfs - struct to supervise multiple nilfs mount points * @ns_flags: flags * @ns_flushed_device: flag indicating if all volatile data was flushed + * @ns_sb: back pointer to super block instance * @ns_bdev: block device * @ns_sem: semaphore for shared states * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts @@ -102,6 +103,7 @@ struct the_nilfs { unsigned long ns_flags; int ns_flushed_device; + struct super_block *ns_sb; struct block_device*ns_bdev; struct rw_semaphore ns_sem; struct mutexns_snapshot_mount_mutex; @@ -281,7 +283,7 @@ static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs) } void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64); -struct the_nilfs *alloc_nilfs(struct block_device *bdev); +struct the_nilfs *alloc_nilfs(struct super_block *sb); void destroy_nilfs(struct the_nilfs *nilfs); int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data); int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb); -- 1.8.3.1
[PATCH 3/8] nilfs2: embed a back pointer to super block instance in nilfs object
Insert a back pointer to super block instance in nilfs object so that functions of nilfs2 easily refer to the super block instance. This simplifies replacement of printk() in the successive change. Signed-off-by: Ryusuke Konishi --- fs/nilfs2/super.c | 2 +- fs/nilfs2/the_nilfs.c | 7 --- fs/nilfs2/the_nilfs.h | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 86e3c00..2d4d0be 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -1076,7 +1076,7 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent) __u64 cno; int err; - nilfs = alloc_nilfs(sb->s_bdev); + nilfs = alloc_nilfs(sb); if (!nilfs) return -ENOMEM; diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 809bd2d..dbead89 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c @@ -56,12 +56,12 @@ void nilfs_set_last_segment(struct the_nilfs *nilfs, /** * alloc_nilfs - allocate a nilfs object - * @bdev: block device to which the_nilfs is related + * @sb: super block instance * * Return Value: On success, pointer to the_nilfs is returned. * On error, NULL is returned. */ -struct the_nilfs *alloc_nilfs(struct block_device *bdev) +struct the_nilfs *alloc_nilfs(struct super_block *sb) { struct the_nilfs *nilfs; @@ -69,7 +69,8 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev) if (!nilfs) return NULL; - nilfs->ns_bdev = bdev; + nilfs->ns_sb = sb; + nilfs->ns_bdev = sb->s_bdev; atomic_set(>ns_ndirtyblks, 0); init_rwsem(>ns_sem); mutex_init(>ns_snapshot_mount_mutex); diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index 79369fd..79d1421 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h @@ -43,6 +43,7 @@ enum { * struct the_nilfs - struct to supervise multiple nilfs mount points * @ns_flags: flags * @ns_flushed_device: flag indicating if all volatile data was flushed + * @ns_sb: back pointer to super block instance * @ns_bdev: block device * @ns_sem: semaphore for shared states * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts @@ -102,6 +103,7 @@ struct the_nilfs { unsigned long ns_flags; int ns_flushed_device; + struct super_block *ns_sb; struct block_device*ns_bdev; struct rw_semaphore ns_sem; struct mutexns_snapshot_mount_mutex; @@ -281,7 +283,7 @@ static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs) } void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64); -struct the_nilfs *alloc_nilfs(struct block_device *bdev); +struct the_nilfs *alloc_nilfs(struct super_block *sb); void destroy_nilfs(struct the_nilfs *nilfs); int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data); int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb); -- 1.8.3.1