[PATCH] fs/affs: fix potential memory leak in option parsing

2018-05-21 Thread Chengguang Xu
When specifying option 'prefix' multiple times, current option parsing will cause memory leak. Hence, call kfree for previous one in this case. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- fs/affs/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/affs/super.c b/fs/affs/s

[RESEND PATCH] x86: remove redundant check for kmem_cache_create()

2018-06-12 Thread Chengguang Xu
The flag 'SLAB_PANIC' implies panic when encouter failure, so there is no need to check NULL pointer and return error code. Signed-off-by: Chengguang Xu --- arch/x86/mm/pgtable.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm

[PATCH v2] x86: remove redundant check for kmem_cache_create()

2018-06-12 Thread Chengguang Xu
The flag 'SLAB_PANIC' implies panic when encouter failure, So there is no need to check NULL pointer for cache creation. Signed-off-by: Chengguang Xu --- v1->v2: - Keep return type as int instead of changing to void. arch/x86/mm/pgtable.c | 3 --- 1 file changed, 3 deletions(-) diff --

[PATCH 2/2] fs/exofs: only use true/false for asignment of bool type variable

2018-06-12 Thread Chengguang Xu
Signed-off-by: Chengguang Xu --- fs/exofs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/exofs/super.c b/fs/exofs/super.c index f3e17a9..75b5db0 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c @@ -118,7 +118,7 @@ static int parse_options(char *options, struct

[PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing

2018-06-12 Thread Chengguang Xu
There are some cases can cause memory leak when parsing option 'osdname'. Signed-off-by: Chengguang Xu --- fs/exofs/super.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/exofs/super.c b/fs/exofs/super.c index 719a315..f3e17a9 100644 --- a/fs/exofs/super.c +++ b/fs

[PATCH] kernel/power: cast PAGE_SIZE to int when comparing with error code

2018-06-24 Thread Chengguang Xu
If PAGE_SIZE is unsigned type then negative error code will be larger than PAGE_SIZE. Signed-off-by: Chengguang Xu --- kernel/power/swap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/power/swap.c b/kernel/power/swap.c index c2bcf97d24c8..d7f6c1a288d3 100644

[V9fs-developer][PATCH v3 2/2] fs/9p: detecting invalid options as much as possible

2018-05-03 Thread Chengguang Xu
' and 'access' when detecting -EINVAL. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- Changes since v2: - Introduce a new temporary variable to avoid overriding error code. - Delete redundant continue in error case. Changes since v1: - Do not change behavior when detecting ENOMEM or unreco

[V9fs-developer][PATCH v3 1/2] net/9p: detecting invalid options as much as possible

2018-05-03 Thread Chengguang Xu
' and 'version' when detecting -EINVAL. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- Changes since v2: - Introduce a new temporary variable to avoid overriding error code. Changes since v1: - Do not change behavior when detecting ENOMEM or unrecognized options. net/9p/client.

[PATCH] mm: adjust max read count in generic_file_buffered_read()

2018-07-19 Thread Chengguang Xu
When we try to truncate read count in generic_file_buffered_read(), should deliver (sb->s_maxbytes - offset) as maximum count not sb->s_maxbytes itself. Signed-off-by: Chengguang Xu --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/fil

[PATCH] isofs: fix potential memory leak in mount option parsing

2018-04-14 Thread Chengguang Xu
When specifying string type mount option (e.g., iocharset) several times in a mount, current option parsing may cause memory leak. Hence, call kfree for previous one in this case. Meanwhile, check memory allocation result for it. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- fs

[PATCH] exofs: fix potential memory leak in mount option parsing

2018-04-14 Thread Chengguang Xu
When specifying string type mount option several times in a mount, current option parsing may cause memory leak. Hence, call kfree for previous one in this case. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- fs/exofs/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs

[V9fs-developer][PATCH v2 1/2] net/9p: detecting invalid options as much as possible

2018-04-17 Thread Chengguang Xu
' and 'version' when detecting EINVAL. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- Changes since v1: - Do not change behavior when detecting ENOMEM or unrecognized options. net/9p/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/9p/client.c b/net/9p/cl

[V9fs-developer][PATCH v2 2/2] fs/9p: detecting invalid options as much as possible

2018-04-17 Thread Chengguang Xu
' and 'access' when detecting EINVAL. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- Changes since v1: - Do not change behavior when detecting ENOMEM or unrecognized options. fs/9p/v9fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c

[PATCH 1/2] hfs: fix potential refcnt problem of nls module

2018-04-17 Thread Chengguang Xu
When specifying iocharset/codepage multiple times in a mount, current option parsing will cause inaccurate refcount of nls module. Hence, call unload_nls for previous one in this case. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- fs/hfs/super.c | 8 ++-- 1 file changed, 6 inse

[PATCH 2/2] hfsplus: fix potential refcnt problem of nls module

2018-04-17 Thread Chengguang Xu
When specifying nls option multiple times in a mount, current option parsing will cause inaccurate refcount of nls module. Hence, call unload_nls for previous one in this case. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- fs/hfsplus/options.c | 4 +++- 1 file changed, 3 insertions

[PATCH 2/2] fs/9p: detecting invalid options as much as possible

2018-04-16 Thread Chengguang Xu
and the case of memory allocation error in option parsing. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- fs/9p/v9fs.c | 49 - 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index e622f0f..29ba937

[PATCH 1/2] net/9p: detecting invalid options as much as possible

2018-04-16 Thread Chengguang Xu
and the case of memory allocation error in option parsing. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- net/9p/client.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 21e6df1..066f136 100644 --- a/net/9p/client.c

(Resend) Re: 回复:[PATCH] fs/overlayfs: Drop dentry cache to prevent unknown file status

2018-03-20 Thread Chengguang Xu
it first and check if the problem still persist. The phenomenon I met is similar to yours in the previous email. Thanks, Chengguang.   - Sent: Tuesday, March 20, 2018 at 3:22 PM From: 王元良 <yuanliang@alibaba-inc.com> To: "Chengguang Xu" <cgxu...@gmx.com>,

Re: [PATCH] fs/overlayfs: Drop dentry cache to prevent unknown file status

2018-03-20 Thread Chengguang Xu
Hi Yuanliang, Can you explain how to reproduce it? and what filesystem do you use as underlying fs? > Sent: Tuesday, March 20, 2018 at 2:03 PM > From: 王元良 > To: mik...@szeredi.hu > Cc: linux-unio...@vger.kernel.org, linux-kernel@vger.kernel.org, 王元良 >

Re: [PATCH] fs/overlayfs: Drop dentry cache to prevent unknown file status

2018-03-20 Thread Chengguang Xu
Hi Yuanliang, Can you try ext4 or xfs(with ftype=1) as underlying fs? It seems the phenomenon that I met on xfs(with ftype=0) as underlying fs. Thanks, Chengguang. > Sent: Tuesday, March 20, 2018 at 2:44 PM > From: "Chengguang Xu" <cgxu...@gmx.com> > To: 王元良 <y

[PATCH] 9p: check memory allocation result for cachetag

2018-03-21 Thread Chengguang Xu
Check memory allocation result for cachetag in mount option parsing and fix potential memory leak in the error case. Signed-off-by: Chengguang Xu <cgxu...@gmx.com> --- fs/9p/v9fs.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 8fb89dd..e

[PATCH] udf: fix potential refcnt problem of nls module

2018-02-25 Thread Chengguang Xu
When specifiying iocharset multiple times in a mount or once/multiple in a remount, current option parsing may cause inaccurate refcount of nls module. Also, in the failure cleanup of option parsing, the condition of calling unload_nls is not sufficient. Signed-off-by: Chengguang Xu <c

Re: [PATCH] fs/overlayfs: Drop dentry cache to prevent unknown file status

2018-03-20 Thread Chengguang Xu
Hi Yuanliang, Can you explain how to reproduce it? and what filesystem do you use as underlying fs? > Sent: Tuesday, March 20, 2018 at 2:03 PM > From: 王元良 > To: mik...@szeredi.hu > Cc: linux-unio...@vger.kernel.org, linux-kernel@vger.kernel.org, 王元良 > > Subject: [PATCH] fs/overlayfs: Drop

Re: [PATCH] fs/overlayfs: Drop dentry cache to prevent unknown file status

2018-03-20 Thread Chengguang Xu
Hi Yuanliang, Can you try ext4 or xfs(with ftype=1) as underlying fs? It seems the phenomenon that I met on xfs(with ftype=0) as underlying fs. Thanks, Chengguang. > Sent: Tuesday, March 20, 2018 at 2:44 PM > From: "Chengguang Xu" > To: 王元良 > Cc: mik...@

(Resend) Re: 回复:[PATCH] fs/overlayfs: Drop dentry cache to prevent unknown file status

2018-03-20 Thread Chengguang Xu
it first and check if the problem still persist. The phenomenon I met is similar to yours in the previous email. Thanks, Chengguang.   - Sent: Tuesday, March 20, 2018 at 3:22 PM From: 王元良 To: "Chengguang Xu" , "Chengguang Xu" Cc: miklos , linux-unionfs , linux-kernel

[PATCH] 9p: check memory allocation result for cachetag

2018-03-21 Thread Chengguang Xu
Check memory allocation result for cachetag in mount option parsing and fix potential memory leak in the error case. Signed-off-by: Chengguang Xu --- fs/9p/v9fs.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 8fb89dd..e622f0f 100644 --- a/fs/9p

[V9fs-developer][PATCH v3 1/2] net/9p: detecting invalid options as much as possible

2018-05-03 Thread Chengguang Xu
' and 'version' when detecting -EINVAL. Signed-off-by: Chengguang Xu --- Changes since v2: - Introduce a new temporary variable to avoid overriding error code. Changes since v1: - Do not change behavior when detecting ENOMEM or unrecognized options. net/9p/client.c | 13 + 1 file

[V9fs-developer][PATCH v3 2/2] fs/9p: detecting invalid options as much as possible

2018-05-03 Thread Chengguang Xu
' and 'access' when detecting -EINVAL. Signed-off-by: Chengguang Xu --- Changes since v2: - Introduce a new temporary variable to avoid overriding error code. - Delete redundant continue in error case. Changes since v1: - Do not change behavior when detecting ENOMEM or unrecognized options. fs/9p

[PATCH] isofs: fix potential memory leak in mount option parsing

2018-04-14 Thread Chengguang Xu
When specifying string type mount option (e.g., iocharset) several times in a mount, current option parsing may cause memory leak. Hence, call kfree for previous one in this case. Meanwhile, check memory allocation result for it. Signed-off-by: Chengguang Xu --- fs/isofs/inode.c | 3 +++ 1 file

[PATCH] exofs: fix potential memory leak in mount option parsing

2018-04-14 Thread Chengguang Xu
When specifying string type mount option several times in a mount, current option parsing may cause memory leak. Hence, call kfree for previous one in this case. Signed-off-by: Chengguang Xu --- fs/exofs/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/exofs/super.c b/fs/exofs

[PATCH 2/2] fs/9p: detecting invalid options as much as possible

2018-04-16 Thread Chengguang Xu
and the case of memory allocation error in option parsing. Signed-off-by: Chengguang Xu --- fs/9p/v9fs.c | 49 - 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index e622f0f..29ba937 100644 --- a/fs/9p/v9fs.c

[PATCH 1/2] net/9p: detecting invalid options as much as possible

2018-04-16 Thread Chengguang Xu
and the case of memory allocation error in option parsing. Signed-off-by: Chengguang Xu --- net/9p/client.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 21e6df1..066f136 100644 --- a/net/9p/client.c +++ b/net/9p/client.c

[V9fs-developer][PATCH v2 2/2] fs/9p: detecting invalid options as much as possible

2018-04-17 Thread Chengguang Xu
' and 'access' when detecting EINVAL. Signed-off-by: Chengguang Xu --- Changes since v1: - Do not change behavior when detecting ENOMEM or unrecognized options. fs/9p/v9fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index e622f0f..2c7a0ef

[V9fs-developer][PATCH v2 1/2] net/9p: detecting invalid options as much as possible

2018-04-17 Thread Chengguang Xu
' and 'version' when detecting EINVAL. Signed-off-by: Chengguang Xu --- Changes since v1: - Do not change behavior when detecting ENOMEM or unrecognized options. net/9p/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 21e6df1

[PATCH 1/2] hfs: fix potential refcnt problem of nls module

2018-04-17 Thread Chengguang Xu
When specifying iocharset/codepage multiple times in a mount, current option parsing will cause inaccurate refcount of nls module. Hence, call unload_nls for previous one in this case. Signed-off-by: Chengguang Xu --- fs/hfs/super.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions

[PATCH 2/2] hfsplus: fix potential refcnt problem of nls module

2018-04-17 Thread Chengguang Xu
When specifying nls option multiple times in a mount, current option parsing will cause inaccurate refcount of nls module. Hence, call unload_nls for previous one in this case. Signed-off-by: Chengguang Xu --- fs/hfsplus/options.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff

[PATCH] udf: fix potential refcnt problem of nls module

2018-02-25 Thread Chengguang Xu
When specifiying iocharset multiple times in a mount or once/multiple in a remount, current option parsing may cause inaccurate refcount of nls module. Also, in the failure cleanup of option parsing, the condition of calling unload_nls is not sufficient. Signed-off-by: Chengguang Xu --- Hi Jan

[RFC PATCH] 9p: create writeback fid on shared mmap

2020-12-05 Thread Chengguang Xu
If vma is shared and the file was opened for writing, we should also create writeback fid because vma may be mprotected writable even if now readonly. Signed-off-by: Chengguang Xu --- Caveat: Only compile tested. fs/9p/vfs_file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff

Re: [V9fs-developer] [RFC PATCH] 9p: create writeback fid on shared mmap

2020-12-06 Thread Chengguang Xu
在 星期一, 2020-12-07 04:53:18 Dominique Martinet 撰写 > Dominique Martinet wrote on Sun, Dec 06, 2020: > > Chengguang Xu wrote on Sat, Dec 05, 2020: > > > If vma is shared and the file was opened for writing, > > > we should also create wr

[PATCH] 9p: avoid attaching writeback_fid on mmap with type PRIVATE

2019-08-20 Thread Chengguang Xu
-by: Chengguang Xu --- fs/9p/vfs_file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 4cc966a31cb3..fe7f0bd2048e 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -513,6 +513,7 @@ v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct

[PATCH] quota: fix condition for resetting time limit in do_set_dqblk()

2019-07-23 Thread Chengguang Xu
We reset time limit when current usage is smaller or equal to soft limit in other place, so follow this rule in do_set_dqblk(). Signed-off-by: Chengguang Xu --- fs/quota/dquot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index

[PATCH] qnx6: convert mount option checking code to test_opt()

2019-05-21 Thread Chengguang Xu
Convert mount option checking code to test_opt() in qnx6_show_options(). Signed-off-by: Chengguang Xu --- fs/qnx6/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c index 59cf45f6be49..c3a80700e7a6 100644 --- a/fs/qnx6/inode.c +++ b

[PATCH] quota: avoid increasing DQST_LOOKUPS when iterating over dirty/inuse list

2019-09-26 Thread Chengguang Xu
It is meaningless to increase DQST_LOOKUPS number while iterating over dirty/inuse list, so just avoid it. Signed-off-by: Chengguang Xu --- fs/quota/dquot.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 6e826b454082..00a3c6df2ea3 100644 --- a/fs

[PATCH] quota: code cleanup for hash bits calculation

2019-09-20 Thread Chengguang Xu
Code cleanup for hash bits calculation by calling rounddown_pow_of_two() and ilog2() Signed-off-by: Chengguang Xu --- fs/quota/dquot.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 6e826b454082..679dd3b5db70 100644 --- a/fs

[PATCH] quota: check quota type in early stage

2019-10-08 Thread Chengguang Xu
Check quota type in early stage so we can avoid many unncessary operations when the type is wrong. Signed-off-by: Chengguang Xu --- fs/quota/quota.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/quota/quota.c b/fs/quota/quota.c index cb13fb76dbee..5444d3c4d93f

[PATCH] hugetlbfs: fix error handling in init_hugetlbfs_fs()

2019-10-17 Thread Chengguang Xu
In order to avoid using incorrect mnt, we should set mnt to NULL when we get error from mount_one_hugetlbfs(). Signed-off-by: Chengguang Xu --- fs/hugetlbfs/inode.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index

(RESEND) [PATCH] ocfs2: Fix error handling in ocfs2_setattr()

2019-10-10 Thread Chengguang Xu
Should set transfer_to[USRQUOTA/GRPQUOTA] to NULL on error case before jump to do dqput(). Signed-off-by: Chengguang Xu --- fs/ocfs2/file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 2e982db3e1ae..53939bf9d7d2 100644 --- a/fs/ocfs2/file.c +++ b

[PATCH] quota: minor code cleanup for v1_format_ops

2019-10-10 Thread Chengguang Xu
It's not a functinal change, it's just for keeping consistent coding style. Signed-off-by: Chengguang Xu --- fs/quota/quota_v1.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c index c740e5572eb8..cd92e5fa0062 100644 --- a/fs/quota/quota_v1.c +++ b

[PATCH v2] quota: code cleanup for hash bits calculation

2019-09-23 Thread Chengguang Xu
Code cleanup for hash bits calculation by calling ilog2(). Signed-off-by: Chengguang Xu --- v1->v2: - Calculate hash bits by directly calling ilog2(). fs/quota/dquot.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c in

[PATCH] quota: minor optimization for __dquot_initialize()

2020-06-20 Thread Chengguang Xu
Count the number of quotas which are needed to initialize, instead of just setting to 1 so that we may avoid unnecessary process in special case. Signed-off-by: Chengguang Xu --- fs/quota/dquot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/quota/dquot.c b/fs/quota

[PATCH] fs/affs: fix potential memory leak in option parsing

2018-05-21 Thread Chengguang Xu
When specifying option 'prefix' multiple times, current option parsing will cause memory leak. Hence, call kfree for previous one in this case. Signed-off-by: Chengguang Xu --- fs/affs/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/affs/super.c b/fs/affs/super.c index e602619

[PATCH] uio: fix potential memory leak in error case

2019-01-17 Thread Chengguang Xu
Should jump to lable err_infoopen when idev->info is NULL in uio_open(). Signed-off-by: Chengguang Xu --- drivers/uio/uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 131342280b46..46e5c1c31ebe 100644 --- a/drivers/uio/ui

[PATCH] kernel/power: cast PAGE_SIZE to int when comparing with error code

2018-06-24 Thread Chengguang Xu
If PAGE_SIZE is unsigned type then negative error code will be larger than PAGE_SIZE. Signed-off-by: Chengguang Xu --- kernel/power/swap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/power/swap.c b/kernel/power/swap.c index c2bcf97d24c8..d7f6c1a288d3 100644

[PATCH] mm: adjust max read count in generic_file_buffered_read()

2018-07-19 Thread Chengguang Xu
When we try to truncate read count in generic_file_buffered_read(), should deliver (sb->s_maxbytes - offset) as maximum count not sb->s_maxbytes itself. Signed-off-by: Chengguang Xu --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/fil

[RESEND PATCH] chardev: set variable ret to -EBUSY before checking minor range overlap

2019-04-26 Thread Chengguang Xu
code analyzing tool(like Smatch) and also make the code more easy to understand. Suggested-by: Dan Carpenter Signed-off-by: Chengguang Xu --- fs/char_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/char_dev.c b/fs/char_dev.c index d18cad28c1c3..00dfe17871ac 100644

[PATCH v2] jbd2: fix potential double free

2019-05-10 Thread Chengguang Xu
When fail from creating cache jbd2_inode_cache, we will destroy previously created cache jbd2_handle_cache twice. This patch fixes it by sperating each cache initialization/destruction to individual function. Signed-off-by: Chengguang Xu --- v2: - Seperate cache initialization/destruction

[PATCH] quota: fix wrong indentation

2019-04-19 Thread Chengguang Xu
We need to check return code only when calling ->read_dqblk(), so fix it properly. Signed-off-by: Chengguang Xu --- fs/quota/dquot.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index fc20e06c56ba..934b8f3f9e57 100644 --- a

[PATCH v2] chardev: set variable ret to -EBUSY before checking minor range overlap

2019-05-02 Thread Chengguang Xu
code analyzing tool(like Smatch) and also make the code more easy to understand. Suggested-by: Dan Carpenter Signed-off-by: Chengguang Xu --- v1->v2: - Rebase against the latest char-misc-next. - Modify signed-off mail address. fs/char_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 delet

[PATCH 2/3] jbd2: code cleanup for jbd2_journal_init_revoke_caches()

2019-05-05 Thread Chengguang Xu
jbd2_journal_destroy_caches() can handle destruction work for all caches, so we don't have to destroy previously created cache in error path, it also makes the code simpler. Signed-off-by: Chengguang Xu --- fs/jbd2/revoke.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff

[PATCH 3/3] jbd2: add __init annotation for jbd2_journal_init_journal_head_cache()

2019-05-05 Thread Chengguang Xu
jbd2_journal_init_journal_head_cache() only be called once, so add __init annotation for it and do some code cleanup. Signed-off-by: Chengguang Xu --- fs/jbd2/journal.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index

[PATCH 1/3] jbd2: fix potential double free

2019-05-05 Thread Chengguang Xu
When fail from creating cache jbd2_inode_cache, we will destroy previously created cache jbd2_handle_cache twice. This patch fixes it by removing first destroy in error path. Signed-off-by: Chengguang Xu --- fs/jbd2/journal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/jbd2/journal.c

[PATCH] ns: modify function comment for projid

2019-05-05 Thread Chengguang Xu
Some function comments about projid are described as uid, so fix it. Signed-off-by: Chengguang Xu --- kernel/user_namespace.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 923414a246e9..6e917fc072d0 100644

[PATCH] quota: add dqi_dirty_list description to comment of Dquot List Management

2019-05-05 Thread Chengguang Xu
Actually there are four lists for dquot management, so add the description of dqui_dirty_list to comment. Signed-off-by: Chengguang Xu --- fs/quota/dquot.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index fc20e06c56ba

[PATCH] quota: set init_needed flag only when successfully getting dquot

2019-04-27 Thread Chengguang Xu
Set init_needed flag only when successfully getting dquot, so that we can skip unnecessary subsequent operation. Signed-off-by: Chengguang Xu --- fs/quota/dquot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index fc20e06c56ba

[PATCH] quota: check time limit when back out space/inode change

2019-04-30 Thread Chengguang Xu
When we fail from allocating inode/space, we back out the change we already did. In a special case which has exceeded soft limit by the change, we should also check time limit and reset it properly. Signed-off-by: Chengguang Xu --- fs/quota/dquot.c | 14 ++ 1 file changed, 6

[PATCH] quota: code cleanup for __dquot_alloc_space()

2019-03-19 Thread Chengguang Xu
Replace (flags & DQUOT_SPACE_RESERVE) with variable reserve. Signed-off-by: Chengguang Xu --- fs/quota/dquot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index fc20e06c56ba..00de508f9d2e 100644 --- a/fs/quota/dquot.c +++

[PATCH v3 1/4] chardev: add additional check for minor range overlap

2019-04-05 Thread Chengguang Xu
Current overlap checking cannot correctly handle a case which is baseminor < existing baseminor && baseminor + minorct > existing baseminor + minorct. Signed-off-by: Chengguang Xu --- v1->v2: - Split fix and cleanup patches. - Remove printing minor range in chrdev_show().

[PATCH v3 2/4] chardev: add a check for given minor range

2019-04-05 Thread Chengguang Xu
register_chrdev_region() carefully checks minor range before calling __register_chrdev_region() but there is another path from alloc_chrdev_region() which does not check the range properly. So add a check for given minor range in __register_chrdev_region(). Signed-off-by: Chengguang Xu --- v1

[PATCH v3 4/4] chardev: update comment based on the code

2019-04-05 Thread Chengguang Xu
The function comment of __register_chrdev_region() is out of date, so update it based on the code. Signed-off-by: Chengguang Xu --- v1->v2: - Split fix and cleanup patches. - Remove printing minor range in chrdev_show(). fs/char_dev.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deleti

[PATCH v3 3/4] chardev: code cleanup for __register_chrdev_region()

2019-04-05 Thread Chengguang Xu
It's just code cleanup, not functional change. Signed-off-by: Chengguang Xu --- v1->v2: - Split fix and cleanup patches. - Remove printing minor range in chrdev_show(). v2->v3: - Set variable ret to '-EBUSY' before checking minor range overlap. fs/char_dev.

Re: [PATCH v3 3/4] chardev: code cleanup for __register_chrdev_region()

2019-04-05 Thread Chengguang Xu
> Sent: Friday, April 05, 2019 at 8:32 PM > From: "Greg KH" > To: "Chengguang Xu" > Cc: dan.carpen...@oracle.com, linux-fsde...@vger.kernel.org, > v...@zeniv.linux.org.uk, linux-kernel@vger.kernel.org > Subject: Re: [PATCH v3 3/4] chardev: code c

[PATCH] chardev: set variable ret to -EBUSY before checking minor range overlap

2019-04-05 Thread Chengguang Xu
code analyzing tool(like Smatch) and also make the code more easy to understand. Suggested-by: Dan Carpenter Signed-off-by: Chengguang Xu --- fs/char_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/char_dev.c b/fs/char_dev.c index df6a54045ac4..00dfe17871ac 100644

[PATCH] quota: remvoe redundant variable assignment

2019-04-14 Thread Chengguang Xu
The assignment of variable ret is redundant because the value of ret is 0 after calling v2_read_header() in normal case. Signed-off-by: Chengguang Xu --- fs/quota/quota_v2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c index a73e5b34db41

[PATCH] mei: expand minor range when registering chrdev region

2019-02-11 Thread Chengguang Xu
Actually, total amount of available minor number for a single major is MINORMARK + 1. So expand minor range when registering chrdev region. Signed-off-by: Chengguang Xu --- drivers/misc/mei/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/mei/main.c b

[PATCH 1/2] chardev: fix an overlap misjudgement case in __register_chrdev_region()

2019-02-12 Thread Chengguang Xu
Current overlap check of minor range cannot correctly handle a case which is baseminor < existing baseminor && baseminor + minorct > existing baseminor + minorct. Fix it and meanwhile do some code cleanups. Fixes: 01d553d0fe9f90 ("Chardev checking of overlapping ranges") S

[PATCH 2/2] chardev: showing minor range for chardev in the output of /proc/devices

2019-02-12 Thread Chengguang Xu
Currently chardev allows to share major, showing major with minor range for chardev will be more helpful. Signed-off-by: Chengguang Xu --- fs/char_dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/char_dev.c b/fs/char_dev.c index b25b1da097d5..6f00acdeb308 100644

[PATCH v2 1/4] chardev: add additional check for minor range overlap

2019-02-15 Thread Chengguang Xu
Current overlap checking cannot correctly handle a case which is baseminor < existing baseminor && baseminor + minorct > existing baseminor + minorct. Signed-off-by: Chengguang Xu --- v1->v2: - Split fix and cleanup patches. - Remove printing minor range in chrdev_show().

[PATCH v2 4/4] chardev: update comment based on the code

2019-02-15 Thread Chengguang Xu
The function comment of __register_chrdev_region() is out of date, so update it based on the code. Signed-off-by: Chengguang Xu --- v1->v2: - Split fix and cleanup patches. - Remove printing minor range in chrdev_show(). fs/char_dev.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deleti

[PATCH v2 2/4] chardev: add a check for given minor range

2019-02-15 Thread Chengguang Xu
register_chrdev_region() carefully checks minor range before calling __register_chrdev_region() but there is another path from alloc_chrdev_region() which does not check the range properly. So add a check for given minor range in __register_chrdev_region(). Signed-off-by: Chengguang Xu --- v1

[PATCH v2 3/4] chardev: code cleanup for __register_chrdev_region()

2019-02-15 Thread Chengguang Xu
It's just code cleanup, not functional change. Signed-off-by: Chengguang Xu --- v1->v2: - Split fix and cleanup patches. - Remove printing minor range in chrdev_show(). fs/char_dev.c | 69 +-- 1 file changed, 28 insertions(+), 41 deleti

[PATCH 2/2] proc: code cleanup for proc_setup_thread_self()

2019-01-23 Thread Chengguang Xu
Remove unnecessary ERR_PTR()/PTR_ERR() cast in proc_setup_thread_self(). Signed-off-by: Chengguang Xu --- fs/proc/thread_self.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c index b905010ca9eb..f61ae53533f5

[PATCH 1/2] proc: code cleanup for proc_setup_self()

2019-01-23 Thread Chengguang Xu
Remove unnecessary ERR_PTR()/PTR_ERR() cast in proc_setup_self(). Signed-off-by: Chengguang Xu --- fs/proc/self.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/proc/self.c b/fs/proc/self.c index 127265e5c55f..57c0a1047250 100644 --- a/fs/proc/self.c

[PATCH] uio: remove redundant check

2019-01-19 Thread Chengguang Xu
It is not necessary to check idev->info several times under mutex lock, so just remove redundant check. Signed-off-by: Chengguang Xu --- drivers/uio/uio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 46e5c1c31

[RESEND PATCH] x86: remove redundant check for kmem_cache_create()

2018-06-12 Thread Chengguang Xu
The flag 'SLAB_PANIC' implies panic when encouter failure, so there is no need to check NULL pointer and return error code. Signed-off-by: Chengguang Xu --- arch/x86/mm/pgtable.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm

[PATCH v2] x86: remove redundant check for kmem_cache_create()

2018-06-12 Thread Chengguang Xu
The flag 'SLAB_PANIC' implies panic when encouter failure, So there is no need to check NULL pointer for cache creation. Signed-off-by: Chengguang Xu --- v1->v2: - Keep return type as int instead of changing to void. arch/x86/mm/pgtable.c | 3 --- 1 file changed, 3 deletions(-) diff --

[PATCH 2/2] fs/exofs: only use true/false for asignment of bool type variable

2018-06-12 Thread Chengguang Xu
Signed-off-by: Chengguang Xu --- fs/exofs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/exofs/super.c b/fs/exofs/super.c index f3e17a9..75b5db0 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c @@ -118,7 +118,7 @@ static int parse_options(char *options, struct

[PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing

2018-06-12 Thread Chengguang Xu
There are some cases can cause memory leak when parsing option 'osdname'. Signed-off-by: Chengguang Xu --- fs/exofs/super.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/exofs/super.c b/fs/exofs/super.c index 719a315..f3e17a9 100644 --- a/fs/exofs/super.c +++ b/fs

Re: [V9fs-developer] [RFC PATCH] 9p: create writeback fid on shared mmap

2020-12-07 Thread Chengguang Xu
在 星期一, 2020-12-07 19:24:10 Dominique Martinet 撰写 > Chengguang Xu wrote on Mon, Dec 07, 2020: > > > , VM_MAYWRITE is set anytime we have a shared map where file has > > > been opened read-write, which seems to be what you want with regards to > > >

[V9fs-developer][PATCH v2] 9p: create writeback fid on shared writable mmap

2020-12-07 Thread Chengguang Xu
If vma is shared and the file was opened for writing, we should also create writeback fid because vma may be mprotected writable even if now readonly. Signed-off-by: Chengguang Xu --- fs/9p/vfs_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/9p/vfs_file.c b/fs/9p

[tip:x86/mm] x86/mm: Remove redundant check for kmem_cache_create()

2018-08-02 Thread tip-bot for Chengguang Xu
Commit-ID: 765d28f136291f9639e3c031a1070fb76d6625c7 Gitweb: https://git.kernel.org/tip/765d28f136291f9639e3c031a1070fb76d6625c7 Author: Chengguang Xu AuthorDate: Tue, 12 Jun 2018 19:48:52 +0800 Committer: Thomas Gleixner CommitDate: Thu, 2 Aug 2018 14:27:35 +0200 x86/mm: Remove

[tip:x86/mm] x86/mm: Remove redundant check for kmem_cache_create()

2018-08-02 Thread tip-bot for Chengguang Xu
Commit-ID: 765d28f136291f9639e3c031a1070fb76d6625c7 Gitweb: https://git.kernel.org/tip/765d28f136291f9639e3c031a1070fb76d6625c7 Author: Chengguang Xu AuthorDate: Tue, 12 Jun 2018 19:48:52 +0800 Committer: Thomas Gleixner CommitDate: Thu, 2 Aug 2018 14:27:35 +0200 x86/mm: Remove