[PATCH 1/3] fs/block_dev.c: need not to check inode->i_bdev in bd_forget()
Its only caller evict() has promised a non-NULL inode->i_bdev. Signed-off-by: Yan Hong --- fs/block_dev.c |8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 38e721b..9bdbd9b 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -669,11 +669,9 @@ void bd_forget(struct inode *inode) struct block_device *bdev = NULL; spin_lock(&bdev_lock); - if (inode->i_bdev) { - if (!sb_is_blkdev_sb(inode->i_sb)) - bdev = inode->i_bdev; - __bd_forget(inode); - } + if (!sb_is_blkdev_sb(inode->i_sb)) + bdev = inode->i_bdev; + __bd_forget(inode); spin_unlock(&bdev_lock); if (bdev) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/3] fs/fs-writeback.c: remove unneccesary parameter of __writeback_single_inode()
The parameter 'wb' is never used in this function. Cc: Wu Fengguang Signed-off-by: Yan Hong --- fs/fs-writeback.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index be3efc4..da746e8 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -438,8 +438,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb, * setting I_SYNC flag and calling inode_sync_complete() to clear it. */ static int -__writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, -struct writeback_control *wbc) +__writeback_single_inode(struct inode *inode, struct writeback_control *wbc) { struct address_space *mapping = inode->i_mapping; long nr_to_write = wbc->nr_to_write; @@ -526,7 +525,7 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, inode->i_state |= I_SYNC; spin_unlock(&inode->i_lock); - ret = __writeback_single_inode(inode, wb, wbc); + ret = __writeback_single_inode(inode, wbc); spin_lock(&wb->list_lock); spin_lock(&inode->i_lock); @@ -673,7 +672,7 @@ static long writeback_sb_inodes(struct super_block *sb, * We use I_SYNC to pin the inode in memory. While it is set * evict_inode() will wait so the inode cannot be freed. */ - __writeback_single_inode(inode, wb, &wbc); + __writeback_single_inode(inode, &wbc); work->nr_pages -= write_chunk - wbc.nr_to_write; wrote += write_chunk - wbc.nr_to_write; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/3] fs/debugsfs: get rid of unnecessary inode->i_private initialization
inode->i_private is promised to be NULL on allocation, no need to set it explicitly. Signed-off-by: Yan Hong --- fs/debugfs/inode.c |1 - 1 file changed, 1 deletion(-) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 4733eab..de2698d 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -59,7 +59,6 @@ static struct inode *debugfs_get_inode(struct super_block *sb, umode_t mode, dev case S_IFDIR: inode->i_op = &simple_dir_inode_operations; inode->i_fop = &simple_dir_operations; - inode->i_private = NULL; /* directory inodes start off with i_nlink == 2 * (for "." entry) */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] scripts/checkpatch.pl: seperate mutiple results with black line
Before: total: 0 errors, 0 warnings, 14 lines checked .patch has no obvious style problems and is ready for submission. total: 0 errors, 0 warnings, 7 lines checked .patch has no obvious style problems and is ready for submission. total: 0 errors, 0 warnings, 25 lines checked .patch has no obvious style problems and is ready for submission. After: total: 0 errors, 0 warnings, 14 lines checked .patch has no obvious style problems and is ready for submission. total: 0 errors, 0 warnings, 7 lines checked .patch has no obvious style problems and is ready for submission. total: 0 errors, 0 warnings, 25 lines checked .patch has no obvious style problems and is ready for submission. Also leave two blank lines after the error message if check fails. Signed-off-by: Yan Hong --- scripts/checkpatch.pl |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index ca05ba2..15d9f08 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3588,7 +3588,7 @@ sub process { print "$filename " if ($summary_file); print "total: $cnt_error errors, $cnt_warn warnings, " . (($check)? "$cnt_chk checks, " : "") . - "$cnt_lines lines checked\n"; + "$cnt_lines lines checked"; print "\n" if ($quiet == 0); } @@ -3617,7 +3617,7 @@ sub process { } if ($clean == 1 && $quiet == 0) { - print "$vname has no obvious style problems and is ready for submission.\n" + print "$vname has no obvious style problems and is ready for submission.\n\n" } if ($clean == 0 && $quiet == 0) { print << "EOM"; @@ -3625,6 +3625,8 @@ $vname has style problems, please review. If any of these errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. + + EOM } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/3] debugfs: pass NULL as the last parameter of debugfs_print_regs32()
Pass NULL instead of empty string to debugfs_print_regs32() when prefix is not used, according to the intention of the code. Signed-off-by: Yan Hong --- drivers/usb/dwc3/debugfs.c |2 +- fs/debugfs/file.c |3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index d4a30f1..6557272 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -382,7 +382,7 @@ static int dwc3_regdump_show(struct seq_file *s, void *unused) seq_printf(s, "DesignWare USB3 Core Register Dump\n"); debugfs_print_regs32(s, dwc3_regs, ARRAY_SIZE(dwc3_regs), -dwc->regs, ""); +dwc->regs, NULL); return 0; } diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index c5ca6ae..3915cc9 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -668,7 +668,8 @@ static int debugfs_show_regset32(struct seq_file *s, void *data) { struct debugfs_regset32 *regset = s->private; - debugfs_print_regs32(s, regset->regs, regset->nregs, regset->base, ""); + debugfs_print_regs32(s, regset->regs, regset->nregs, + regset->base, NULL); return 0; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/3] debugfs: code clean and refactor
debug_fill_super(): return directly if failed to allocate debugfs_fs_info. __create_file(): remove redundant initialization. __debugfs_remove(): remove redundant check. debugfs_positive() already checked dentry->inode is not NULL. Signed-off-by: Yan Hong --- fs/debugfs/inode.c | 37 - 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index b607d92..58eadc1 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -262,10 +262,8 @@ static int debug_fill_super(struct super_block *sb, void *data, int silent) fsi = kzalloc(sizeof(struct debugfs_fs_info), GFP_KERNEL); sb->s_fs_info = fsi; - if (!fsi) { - err = -ENOMEM; - goto fail; - } + if (!fsi) + return -ENOMEM; err = debugfs_parse_options(data, &fsi->mount_opts); if (err) @@ -323,7 +321,6 @@ static struct dentry *__create_file(const char *name, umode_t mode, if (!parent) parent = debugfs_mount->mnt_root; - dentry = NULL; mutex_lock(&parent->d_inode->i_mutex); dentry = lookup_one_len(name, parent, strlen(name)); if (!IS_ERR(dentry)) { @@ -466,23 +463,21 @@ static int __debugfs_remove(struct dentry *dentry, struct dentry *parent) int ret = 0; if (debugfs_positive(dentry)) { - if (dentry->d_inode) { - dget(dentry); - switch (dentry->d_inode->i_mode & S_IFMT) { - case S_IFDIR: - ret = simple_rmdir(parent->d_inode, dentry); - break; - case S_IFLNK: - kfree(dentry->d_inode->i_private); - /* fall through */ - default: - simple_unlink(parent->d_inode, dentry); - break; - } - if (!ret) - d_delete(dentry); - dput(dentry); + dget(dentry); + switch (dentry->d_inode->i_mode & S_IFMT) { + case S_IFDIR: + ret = simple_rmdir(parent->d_inode, dentry); + break; + case S_IFLNK: + kfree(dentry->d_inode->i_private); + /* fall through */ + default: + simple_unlink(parent->d_inode, dentry); + break; } + if (!ret) + d_delete(dentry); + dput(dentry); } return ret; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/3] debugfs: break long lines
Signed-off-by: Yan Hong --- fs/debugfs/file.c | 42 -- fs/debugfs/inode.c | 10 ++ 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 3915cc9..b37eee1 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -95,10 +95,12 @@ struct dentry *debugfs_create_u8(const char *name, umode_t mode, { /* if there are no write bits set, make read only */ if (!(mode & S_IWUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_u8_ro); + return debugfs_create_file(name, mode, parent, value, + &fops_u8_ro); /* if there are no read bits set, make write only */ if (!(mode & S_IRUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_u8_wo); + return debugfs_create_file(name, mode, parent, value, + &fops_u8_wo); return debugfs_create_file(name, mode, parent, value, &fops_u8); } @@ -147,10 +149,12 @@ struct dentry *debugfs_create_u16(const char *name, umode_t mode, { /* if there are no write bits set, make read only */ if (!(mode & S_IWUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_u16_ro); + return debugfs_create_file(name, mode, parent, value, + &fops_u16_ro); /* if there are no read bits set, make write only */ if (!(mode & S_IRUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_u16_wo); + return debugfs_create_file(name, mode, parent, value, + &fops_u16_wo); return debugfs_create_file(name, mode, parent, value, &fops_u16); } @@ -199,10 +203,12 @@ struct dentry *debugfs_create_u32(const char *name, umode_t mode, { /* if there are no write bits set, make read only */ if (!(mode & S_IWUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_u32_ro); + return debugfs_create_file(name, mode, parent, value, +&fops_u32_ro); /* if there are no read bits set, make write only */ if (!(mode & S_IRUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_u32_wo); + return debugfs_create_file(name, mode, parent, value, +&fops_u32_wo); return debugfs_create_file(name, mode, parent, value, &fops_u32); } @@ -252,10 +258,12 @@ struct dentry *debugfs_create_u64(const char *name, umode_t mode, { /* if there are no write bits set, make read only */ if (!(mode & S_IWUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_u64_ro); + return debugfs_create_file(name, mode, parent, value, +&fops_u64_ro); /* if there are no read bits set, make write only */ if (!(mode & S_IRUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_u64_wo); + return debugfs_create_file(name, mode, parent, value, +&fops_u64_wo); return debugfs_create_file(name, mode, parent, value, &fops_u64); } @@ -298,10 +306,12 @@ struct dentry *debugfs_create_x8(const char *name, umode_t mode, { /* if there are no write bits set, make read only */ if (!(mode & S_IWUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_x8_ro); + return debugfs_create_file(name, mode, parent, value, +&fops_x8_ro); /* if there are no read bits set, make write only */ if (!(mode & S_IRUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_x8_wo); + return debugfs_create_file(name, mode, parent, value, +&fops_x8_wo); return debugfs_create_file(name, mode, parent, value, &fops_x8); } @@ -322,10 +332,12 @@ struct dentry *debugfs_create_x16(const char *name, umode_t mode, { /* if there are no write bits set, make read only */ if (!(mode & S_IWUGO)) - return debugfs_create_file(name, mode, parent, value, &fops_x16_ro); + return debugfs_create_file(name, mode, parent, value, +&f
[PATCH 1/5] debugfs: pass NULL as the last parameter of debugfs_print_regs32()
If 'prefix' is not used, pass NULL instead of empty string as the last parameter of debugfs_print_regs32(). Cc: Alessandro Rubini Signed-off-by: Yan Hong --- This function is only used (twice) by the author of it, and the 'prefix' feature is never used. But it's a well-documented debugfs API. It's added one year ago and appeared in many documents. I still prefer to let this API stay unchanged and treat the empty string as typo. drivers/usb/dwc3/debugfs.c |2 +- fs/debugfs/file.c |3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index d4a30f1..6557272 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -382,7 +382,7 @@ static int dwc3_regdump_show(struct seq_file *s, void *unused) seq_printf(s, "DesignWare USB3 Core Register Dump\n"); debugfs_print_regs32(s, dwc3_regs, ARRAY_SIZE(dwc3_regs), -dwc->regs, ""); +dwc->regs, NULL); return 0; } diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index c5ca6ae..6bdd450 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -668,7 +668,8 @@ static int debugfs_show_regset32(struct seq_file *s, void *data) { struct debugfs_regset32 *regset = s->private; - debugfs_print_regs32(s, regset->regs, regset->nregs, regset->base, ""); + debugfs_print_regs32(s, regset->regs, regset->nregs, + regset->base, NULL); return 0; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/5] debugfs: remove redundant initialization in __create_file()
'dentry' has been set to NULL at the beginning of the function. Signed-off-by: Yan Hong --- fs/debugfs/inode.c |1 - 1 file changed, 1 deletion(-) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 11f6514..12f1282 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -321,7 +321,6 @@ static struct dentry *__create_file(const char *name, umode_t mode, if (!parent) parent = debugfs_mount->mnt_root; - dentry = NULL; mutex_lock(&parent->d_inode->i_mutex); dentry = lookup_one_len(name, parent, strlen(name)); if (!IS_ERR(dentry)) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/5] debugfs: remove goto in debugfs_remount()
Simple code clean to remove goto. Signed-off-by: Yan Hong --- fs/debugfs/inode.c |5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 58eadc1..c0b06a3 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -221,12 +221,11 @@ static int debugfs_remount(struct super_block *sb, int *flags, char *data) err = debugfs_parse_options(data, &fsi->mount_opts); if (err) - goto fail; + return err; debugfs_apply_options(sb); -fail: - return err; + return 0; } static int debugfs_show_options(struct seq_file *m, struct dentry *root) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/5] debugfs: remove redundant check in __debugfs_remove()
debugfs_positive() already checked dentry->d_inode is not NUUL, no need to check it again. Signed-off-by: Yan Hong --- fs/debugfs/inode.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 12f1282..58eadc1 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -463,23 +463,21 @@ static int __debugfs_remove(struct dentry *dentry, struct dentry *parent) int ret = 0; if (debugfs_positive(dentry)) { - if (dentry->d_inode) { - dget(dentry); - switch (dentry->d_inode->i_mode & S_IFMT) { - case S_IFDIR: - ret = simple_rmdir(parent->d_inode, dentry); - break; - case S_IFLNK: - kfree(dentry->d_inode->i_private); - /* fall through */ - default: - simple_unlink(parent->d_inode, dentry); - break; - } - if (!ret) - d_delete(dentry); - dput(dentry); + dget(dentry); + switch (dentry->d_inode->i_mode & S_IFMT) { + case S_IFDIR: + ret = simple_rmdir(parent->d_inode, dentry); + break; + case S_IFLNK: + kfree(dentry->d_inode->i_private); + /* fall through */ + default: + simple_unlink(parent->d_inode, dentry); + break; } + if (!ret) + d_delete(dentry); + dput(dentry); } return ret; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/5] debugfs: return directly if failed to allocate memory in debug_fill_super()
If kzalloc failed, memory is not allocated, sb->s_fs_info is NULL. No need to go through clean up code, return -ENOMEM directly. Signed-off-by: Yan Hong --- fs/debugfs/inode.c |6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index b607d92..11f6514 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -262,10 +262,8 @@ static int debug_fill_super(struct super_block *sb, void *data, int silent) fsi = kzalloc(sizeof(struct debugfs_fs_info), GFP_KERNEL); sb->s_fs_info = fsi; - if (!fsi) { - err = -ENOMEM; - goto fail; - } + if (!fsi) + return -ENOMEM; err = debugfs_parse_options(data, &fsi->mount_opts); if (err) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 5/5] debugfs: remove goto in debugfs_remount()
2012/10/27 Greg KH : > On Sat, Oct 27, 2012 at 04:05:29PM +0800, Yan Hong wrote: >> Simple code clean to remove goto. > > There is nothing wrong with gotos on error paths, so this one should > stay. > > greg k-h I thought we use goto on error path because there is no other elegant ways to do the things, but it sounds like goto is still welcome and preferable when we are not in this case. Anyway, this is a simple clean, I do not insist on it. Thanks -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] writeback: fix a typo in comment
Signed-off-by: Yan Hong --- fs/fs-writeback.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 51ea267..e9e619a 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -1032,7 +1032,7 @@ int bdi_writeback_thread(void *data) while (!kthread_freezable_should_stop(NULL)) { /* * Remove own delayed wake-up timer, since we are already awake -* and we'll take care of the preriodic write-back. +* and we'll take care of the periodic write-back. */ del_timer(&wb->wakeup_timer); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] fs/buffer.c: do not inline exported function
It makes no sense to inlines exported function. Signed-off-by: Yan Hong --- init_buffer() is trivial and only get two module users. Maybe we can move it to buffer_head.h. Remove inline is much more simple to make it clean though. fs/buffer.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index b5f0442..69e83ee 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -46,8 +46,7 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); #define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers) -inline void -init_buffer(struct buffer_head *bh, bh_end_io_t *handler, void *private) +void init_buffer(struct buffer_head *bh, bh_end_io_t *handler, void *private) { bh->b_end_io = handler; bh->b_private = private; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] fs/buffer.c: remove redundant initialization in alloc_page_buffers()
buffer_head comes from kmem_cache_zalloc(), no need to zero its field. Signed-off-by: Yan Hong --- init_buffer() can be actually removed too, but I'm afraid someday its semantic will beyond initializing ->b_end_io and ->b_private. fs/buffer.c |3 --- 1 file changed, 3 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 69e83ee..ad87aa6 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -849,13 +849,10 @@ try_again: if (!bh) goto no_grow; - bh->b_bdev = NULL; bh->b_this_page = head; bh->b_blocknr = -1; head = bh; - bh->b_state = 0; - atomic_set(&bh->b_count, 0); bh->b_size = size; /* Link the buffer to its page */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/8] Misc vfs code clean
Yan Hong (8): fs/namespace.c: introduce helper function path_unmounted() fs/namespace.c: remove unused macro MNT_WRITER_UNDERFLOW_LIMIT fs/namespace.c: trivial code clean fs/namespace.c: check permission early in sys_[u]mount fs/namei.c: introduce macro AT_FDINV fs/inode.c: call alloc_inode() in new_inode() directly fs/inode.c: remove outstanding spin lock prefetch vfs: misc comment clean fs/dcache.c | 11 - fs/inode.c| 13 +-- fs/namei.c| 13 ++- fs/namespace.c| 59 - include/linux/fcntl.h |2 ++ 5 files changed, 43 insertions(+), 55 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/8] fs/namespace.c: introduce helper function path_unmounted()
In fs/namespace.c, we verify whether a path is a mountpoint by comparing path->dentry and path->mnt->mnt_root. Introduce path_unmounted() to make code more readable. Signed-off-by: Yan Hong --- fs/namespace.c | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 4d31f73..3fdc239 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1234,6 +1234,11 @@ static int do_umount(struct mount *mnt, int flags) return retval; } +static inline bool path_unmounted(struct path *path) +{ + return path->dentry != path->mnt->mnt_root; +} + /* * Now umount can handle mount points as well as block devices. * This is important for filesystems which use unnamed block devices. @@ -1260,7 +1265,7 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) goto out; mnt = real_mount(path.mnt); retval = -EINVAL; - if (path.dentry != path.mnt->mnt_root) + if (path_unmounted(&path)) goto dput_and_out; if (!check_mnt(mnt)) goto dput_and_out; @@ -1613,7 +1618,7 @@ static int do_change_type(struct path *path, int flag) if (!capable(CAP_SYS_ADMIN)) return -EPERM; - if (path->dentry != path->mnt->mnt_root) + if (path_unmounted(path)) return -EINVAL; type = flags_to_propagation_type(flag); @@ -1727,7 +1732,7 @@ static int do_remount(struct path *path, int flags, int mnt_flags, if (!check_mnt(mnt)) return -EINVAL; - if (path->dentry != path->mnt->mnt_root) + if (path_unmounted(path)) return -EINVAL; err = security_sb_remount(sb, data); @@ -1793,7 +1798,7 @@ static int do_move_mount(struct path *path, char *old_name) goto out1; err = -EINVAL; - if (old_path.dentry != old_path.mnt->mnt_root) + if (path_unmounted(&old_path)) goto out1; if (!mnt_has_parent(old)) @@ -1892,7 +1897,7 @@ static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags) /* Refuse the same filesystem on the same mount point */ err = -EBUSY; if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb && - path->mnt->mnt_root == path->dentry) + !path_unmounted(path)) goto unlock; err = -EINVAL; @@ -2534,11 +2539,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, old.mnt == root.mnt) goto out4; /* loop, on the same file system */ error = -EINVAL; - if (root.mnt->mnt_root != root.dentry) + if (path_unmounted(&root)) goto out4; /* not a mountpoint */ if (!mnt_has_parent(root_mnt)) goto out4; /* not attached */ - if (new.mnt->mnt_root != new.dentry) + if (path_unmounted(&new)) goto out4; /* not a mountpoint */ if (!mnt_has_parent(new_mnt)) goto out4; /* not attached */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/8] fs/namespace.c: trivial code clean
Signed-off-by: Yan Hong --- fs/namespace.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index dd969f8..bbe9014 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -763,7 +763,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void mnt->mnt.mnt_root = root; mnt->mnt.mnt_sb = root->d_sb; - mnt->mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt_mountpoint = root; mnt->mnt_parent = mnt; br_write_lock(&vfsmount_lock); list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts); @@ -798,7 +798,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, atomic_inc(&sb->s_active); mnt->mnt.mnt_sb = sb; mnt->mnt.mnt_root = dget(root); - mnt->mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt_mountpoint = root; mnt->mnt_parent = mnt; br_write_lock(&vfsmount_lock); list_add_tail(&mnt->mnt_instance, &sb->s_mounts); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/8] fs/namespace.c: remove unused macro MNT_WRITER_UNDERFLOW_LIMIT
Its users have gone. Signed-off-by: Yan Hong --- fs/namespace.c |1 - 1 file changed, 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index 3fdc239..dd969f8 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -59,7 +59,6 @@ static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) return tmp & (HASH_SIZE - 1); } -#define MNT_WRITER_UNDERFLOW_LIMIT -(1<<16) /* * allocation is serialized by namespace_sem, but we need the spinlock to -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/8] fs/namespace.c: check permission early in sys_[u]mount
We have several branches in sys_mount, each of them will check CAP_SYS_ADMIN capability seperately. Do this check at the beginning of sys_mount. Also check permission as early as possible in sys_umount. Signed-off-by: Yan Hong --- fs/namespace.c | 26 +++--- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index bbe9014..ca2b6e9 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1256,6 +1256,9 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW)) return -EINVAL; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (!(flags & UMOUNT_NOFOLLOW)) lookup_flags |= LOOKUP_FOLLOW; @@ -1269,10 +1272,6 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) if (!check_mnt(mnt)) goto dput_and_out; - retval = -EPERM; - if (!capable(CAP_SYS_ADMIN)) - goto dput_and_out; - retval = do_umount(mnt, flags); dput_and_out: /* we mustn't call path_put() as that would clear mnt_expiry_mark */ @@ -1296,9 +1295,7 @@ SYSCALL_DEFINE1(oldumount, char __user *, name) static int mount_is_safe(struct path *path) { - if (capable(CAP_SYS_ADMIN)) - return 0; - return -EPERM; + return 0; #ifdef notyet if (S_ISLNK(path->dentry->d_inode->i_mode)) return -EPERM; @@ -1614,9 +1611,6 @@ static int do_change_type(struct path *path, int flag) int type; int err = 0; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (path_unmounted(path)) return -EINVAL; @@ -1725,9 +1719,6 @@ static int do_remount(struct path *path, int flags, int mnt_flags, struct super_block *sb = path->mnt->mnt_sb; struct mount *mnt = real_mount(path->mnt); - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (!check_mnt(mnt)) return -EINVAL; @@ -1774,8 +1765,6 @@ static int do_move_mount(struct path *path, char *old_name) struct mount *p; struct mount *old; int err = 0; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; if (!old_name || !*old_name) return -EINVAL; err = kern_path(old_name, LOOKUP_FOLLOW, &old_path); @@ -1924,10 +1913,6 @@ static int do_new_mount(struct path *path, char *type, int flags, if (!type) return -EINVAL; - /* we need capabilities... */ - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - mnt = do_kern_mount(type, flags, name, data); if (IS_ERR(mnt)) return PTR_ERR(mnt); @@ -2410,6 +2395,9 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, char *kernel_dev; unsigned long data_page; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + ret = copy_mount_string(type, &kernel_type); if (ret < 0) goto out_type; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/8] fs/namei.c: introduce macro AT_FDINV
File descriptor is irrelevent when LOOKUP_ROOT is set. Introduce AT_FDINV to avoid using hard coded value or reusing existing macro. Signed-off-by: Yan Hong --- fs/namei.c| 11 ++- include/linux/fcntl.h |2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index c5b85b3..5ffd97d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2034,8 +2034,8 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, nd.root.dentry = dentry; nd.root.mnt = mnt; BUG_ON(flags & LOOKUP_PARENT); - /* the first argument of do_path_lookup() is ignored with LOOKUP_ROOT */ - err = do_path_lookup(AT_FDCWD, name, flags | LOOKUP_ROOT, &nd); + + err = do_path_lookup(AT_FDINV, name, flags | LOOKUP_ROOT, &nd); if (!err) *path = nd.path; return err; @@ -2969,11 +2969,12 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt, if (dentry->d_inode->i_op->follow_link && op->intent & LOOKUP_OPEN) return ERR_PTR(-ELOOP); - file = path_openat(-1, name, &nd, op, flags | LOOKUP_RCU); + file = path_openat(AT_FDINV, name, &nd, op, flags | LOOKUP_RCU); if (unlikely(file == ERR_PTR(-ECHILD))) - file = path_openat(-1, name, &nd, op, flags); + file = path_openat(AT_FDINV, name, &nd, op, flags); if (unlikely(file == ERR_PTR(-ESTALE))) - file = path_openat(-1, name, &nd, op, flags | LOOKUP_REVAL); + file = path_openat(AT_FDINV, name, &nd, op, + flags | LOOKUP_REVAL); return file; } diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h index f550f89..abd94fe 100644 --- a/include/linux/fcntl.h +++ b/include/linux/fcntl.h @@ -41,6 +41,8 @@ #define AT_FDCWD -100/* Special value used to indicate openat should use the current working directory. */ +#define AT_FDINV -200/* Special value used when LOOKUP_ROOT + is set. */ #define AT_SYMLINK_NOFOLLOW0x100 /* Do not follow symbolic links. */ #define AT_REMOVEDIR 0x200 /* Remove directory instead of unlinking file. */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 6/8] fs/inode.c: call alloc_inode() in new_inode() directly
This saves us a list head initialization. Signed-off-by: Yan Hong --- fs/inode.c |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index ac8d904..3a2cd41 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -921,9 +921,11 @@ struct inode *new_inode(struct super_block *sb) spin_lock_prefetch(&inode_sb_list_lock); - inode = new_inode_pseudo(sb); - if (inode) + inode = alloc_inode(sb); + if (inode) { + inode->i_state = 0; inode_sb_list_add(inode); + } return inode; } EXPORT_SYMBOL(new_inode); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 7/8] fs/inode.c: remove outstanding spin lock prefetch
Do we have particular reason to do this here? Signed-off-by: Yan Hong --- fs/inode.c |3 --- 1 file changed, 3 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 3a2cd41..e89d30c 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -14,7 +14,6 @@ #include #include #include -#include #include /* for inode_has_buffers */ #include #include "internal.h" @@ -919,8 +918,6 @@ struct inode *new_inode(struct super_block *sb) { struct inode *inode; - spin_lock_prefetch(&inode_sb_list_lock); - inode = alloc_inode(sb); if (inode) { inode->i_state = 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 8/8] vfs: misc comment clean
Mostly fix comments which reference inexist locks or parameters. Signed-off-by: Yan Hong --- fs/dcache.c| 12 fs/inode.c |4 ++-- fs/namei.c |2 +- fs/namespace.c |9 +++-- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 8086636..2d97518 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -44,8 +44,6 @@ * Usage: * dcache->d_inode->i_lock protects: * - i_dentry, d_alias, d_inode of aliases - * dcache_hash_bucket lock protects: - * - the dcache hash table * s_anon bl list spinlock protects: * - the s_anon list (see __d_drop) * dcache_lru_lock protects: @@ -64,7 +62,6 @@ * dentry->d_inode->i_lock * dentry->d_lock * dcache_lru_lock - * dcache_hash_bucket lock * s_anon lock * * If there is an ancestor relationship: @@ -145,10 +142,9 @@ int proc_nr_dentry(ctl_table *table, int write, void __user *buffer, #include /* - * NOTE! 'cs' and 'scount' come from a dentry, so it has a - * aligned allocation for this particular component. We don't - * strictly need the load_unaligned_zeropad() safety, but it - * doesn't hurt either. + * NOTE! 'cs' comes from a dentry, so it has an aligned allocation + * for this particular component. We don't strictly need the + * load_unaligned_zeropad() safety, but it doesn't hurt either. * * In contrast, 'ct' and 'tcount' can be from a pathname, and do * need the careful unaligned handling. @@ -304,7 +300,7 @@ static void dentry_unlink_inode(struct dentry * dentry) } /* - * dentry_lru_(add|del|prune|move_tail) must be called with d_lock held. + * dentry_lru_(add|del|prune|move_list) must be called with d_lock held. */ static void dentry_lru_add(struct dentry *dentry) { diff --git a/fs/inode.c b/fs/inode.c index e89d30c..46d4f16 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -676,7 +676,7 @@ static int can_unuse(struct inode *inode) * Walk the superblock inode LRU for freeable inodes and attempt to free them. * This is called from the superblock shrinker function with a number of inodes * to trim from the LRU. Inodes to be freed are moved to a temporary list and - * then are freed outside inode_lock by dispose_list(). + * then are freed outside s_inode_lru_lock by dispose_list(). * * Any inodes which are pinned purely because of attached pagecache have their * pagecache removed. If the inode has metadata buffers attached to @@ -777,7 +777,7 @@ void prune_icache_sb(struct super_block *sb, int nr_to_scan) static void __wait_on_freeing_inode(struct inode *inode); /* - * Called with the inode lock held. + * Called with the inode_hash_lock held. */ static struct inode *find_inode(struct super_block *sb, struct hlist_head *head, diff --git a/fs/namei.c b/fs/namei.c index 5ffd97d..7b1f714 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -421,7 +421,7 @@ EXPORT_SYMBOL(path_put); * Path walking has 2 modes, rcu-walk and ref-walk (see * Documentation/filesystems/path-lookup.txt). In situations when we can't * continue in RCU mode, we attempt to drop out of rcu-walk mode and grab - * normal reference counts on dentries and vfsmounts to transition to rcu-walk + * normal reference counts on dentries and vfsmounts to transition to ref-walk * mode. Refcounts are grabbed at the last known good point before rcu-walk * got stuck, so ref-walk may continue from there. If this is not successful * (eg. a seqcount has changed), then failure is returned and it's up to caller diff --git a/fs/namespace.c b/fs/namespace.c index ca2b6e9..b7477ee 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1239,9 +1239,6 @@ static inline bool path_unmounted(struct path *path) } /* - * Now umount can handle mount points as well as block devices. - * This is important for filesystems which use unnamed block devices. - * * We now support a flag for forced unmount like the other 'big iron' * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD */ @@ -1431,9 +1428,9 @@ static int invent_group_ids(struct mount *mnt, bool recurse) } /* - * @source_mnt : mount tree to be attached - * @nd : place the mount tree @source_mnt is attached - * @parent_nd : if non-null, detach the source_mnt from its parent and + * @source_mnt : mount tree to be attached + * @path: place the mount tree @source_mnt is attached + * @parent_path : if non-null, detach the @source_mnt from its parent and *store the parent mount and mountpoint dentry. *(done when source_mnt is moved) * -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/