From 2a5cac17c06f897537f91f0040b3d3c8177f6433 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 24 May 2011 17:13:42 -0700 Subject: fs/ncpfs/inode.c: suppress used-uninitialised warning We get this spurious warning: fs/ncpfs/inode.c: In function 'ncp_fill_super': fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[1u]' may be used uninitialized in this function fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[2u]' may be used uninitialized in this function fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[3u]' may be used uninitialized in this function ... It's notabug, but we can easily fix it with a memset(). Reported-by: Harry Wei Cc: Petr Vandrovec Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/ncpfs/inode.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'fs/ncpfs') diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index 0250e4ce489..202f370526a 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c @@ -461,7 +461,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) #endif struct ncp_entry_info finfo; - data.wdog_pid = NULL; + memset(&data, 0, sizeof(data)); server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL); if (!server) return -ENOMEM; @@ -496,7 +496,6 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) struct ncp_mount_data_v4* md = (struct ncp_mount_data_v4*)raw_data; data.flags = md->flags; - data.int_flags = 0; data.mounted_uid = md->mounted_uid; data.wdog_pid = find_get_pid(md->wdog_pid); data.ncp_fd = md->ncp_fd; @@ -507,7 +506,6 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) data.file_mode = md->file_mode; data.dir_mode = md->dir_mode; data.info_fd = -1; - data.mounted_vol[0] = 0; } break; default: -- cgit v1.2.3 From 79bf7c732b5ff75b96022ed9d29181afd3d2509c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 24 May 2011 13:06:06 -0700 Subject: vfs: push dentry_unhash on rmdir into file systems Only a few file systems need this. Start by pushing it down into each fs rmdir method (except gfs2 and xfs) so it can be dealt with on a per-fs basis. This does not change behavior for any in-tree file systems. Acked-by: Christoph Hellwig Signed-off-by: Sage Weil Signed-off-by: Al Viro --- fs/ncpfs/dir.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fs/ncpfs') diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index f6946bb5cb5..57336b7cb55 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -1033,6 +1033,8 @@ static int ncp_rmdir(struct inode *dir, struct dentry *dentry) DPRINTK("ncp_rmdir: removing %s/%s\n", dentry->d_parent->d_name.name, dentry->d_name.name); + dentry_unhash(dentry); + error = -EBUSY; if (!d_unhashed(dentry)) goto out; -- cgit v1.2.3 From e4eaac06bcccb2a70bca6a2de9871882dce2aa14 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 24 May 2011 13:06:07 -0700 Subject: vfs: push dentry_unhash on rename_dir into file systems Only a few file systems need this. Start by pushing it down into each rename method (except gfs2 and xfs) so that it can be dealt with on a per-fs basis. Acked-by: Christoph Hellwig Signed-off-by: Sage Weil Signed-off-by: Al Viro --- fs/ncpfs/dir.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fs/ncpfs') diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 57336b7cb55..e3e646b0640 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -1141,6 +1141,9 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry, old_dentry->d_parent->d_name.name, old_dentry->d_name.name, new_dentry->d_parent->d_name.name, new_dentry->d_name.name); + if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) + dentry_unhash(new_dentry); + ncp_age_dentry(server, old_dentry); ncp_age_dentry(server, new_dentry); -- cgit v1.2.3 From 456f998ec817ebfa254464be4f089542fa390645 Mon Sep 17 00:00:00 2001 From: Ying Han Date: Thu, 26 May 2011 16:25:38 -0700 Subject: memcg: add the pagefault count into memcg stats Two new stats in per-memcg memory.stat which tracks the number of page faults and number of major page faults. "pgfault" "pgmajfault" They are different from "pgpgin"/"pgpgout" stat which count number of pages charged/discharged to the cgroup and have no meaning of reading/ writing page to disk. It is valuable to track the two stats for both measuring application's performance as well as the efficiency of the kernel page reclaim path. Counting pagefaults per process is useful, but we also need the aggregated value since processes are monitored and controlled in cgroup basis in memcg. Functional test: check the total number of pgfault/pgmajfault of all memcgs and compare with global vmstat value: $ cat /proc/vmstat | grep fault pgfault 1070751 pgmajfault 553 $ cat /dev/cgroup/memory.stat | grep fault pgfault 1071138 pgmajfault 553 total_pgfault 1071142 total_pgmajfault 553 $ cat /dev/cgroup/A/memory.stat | grep fault pgfault 199 pgmajfault 0 total_pgfault 199 total_pgmajfault 0 Performance test: run page fault test(pft) wit 16 thread on faulting in 15G anon pages in 16G container. There is no regression noticed on the "flt/cpu/s" Sample output from pft: TAG pft:anon-sys-default: Gb Thr CLine User System Wall flt/cpu/s fault/wsec 15 16 1 0.67s 233.41s 14.76s 16798.546 266356.260 +-------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 10 16682.962 17344.027 16913.524 16928.812 166.5362 + 10 16695.568 16923.896 16820.604 16824.652 84.816568 No difference proven at 95.0% confidence [akpm@linux-foundation.org: fix build] [hughd@google.com: shmem fix] Signed-off-by: Ying Han Acked-by: KAMEZAWA Hiroyuki Cc: KOSAKI Motohiro Reviewed-by: Minchan Kim Cc: Daisuke Nishimura Acked-by: Balbir Singh Signed-off-by: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/ncpfs/mmap.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fs/ncpfs') diff --git a/fs/ncpfs/mmap.c b/fs/ncpfs/mmap.c index a7c07b44b10..e5d71b27a5b 100644 --- a/fs/ncpfs/mmap.c +++ b/fs/ncpfs/mmap.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -92,6 +93,7 @@ static int ncp_file_mmap_fault(struct vm_area_struct *area, * -- wli */ count_vm_event(PGMAJFAULT); + mem_cgroup_count_vm_event(area->vm_mm, PGMAJFAULT); return VM_FAULT_MAJOR; } -- cgit v1.2.3 From 7ce605d93b775e8a960b0be244f7be565e73b3c1 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 27 May 2011 13:42:09 -0700 Subject: ncpfs: document dentry_unhash usage ncpfs returns EBUSY if there are any references to the directory. The dentry_unhash call only unhashes the dentry if there are no references. CC: Petr Vandrovec CC: linux-kernel@vger.kernel.org Signed-off-by: Sage Weil Signed-off-by: Al Viro --- fs/ncpfs/dir.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'fs/ncpfs') diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index e3e646b0640..81c287d105d 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -1033,8 +1033,11 @@ static int ncp_rmdir(struct inode *dir, struct dentry *dentry) DPRINTK("ncp_rmdir: removing %s/%s\n", dentry->d_parent->d_name.name, dentry->d_name.name); + /* + * fail with EBUSY if there are still references to this + * directory. + */ dentry_unhash(dentry); - error = -EBUSY; if (!d_unhashed(dentry)) goto out; -- cgit v1.2.3 From 76cc071a06afb4d2dd17bb1b855a233a419e7e02 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 27 May 2011 13:42:10 -0700 Subject: ncpfs: fix rename over directory with dangling references ncpfs does not handle references to unlinked directories (or so it would seem given the ncp_rmdir check). Since it is also possible to rename over an empty directory, perform the same check here. CC: Petr Vandrovec CC: linux-kernel@vger.kernel.org Signed-off-by: Sage Weil Signed-off-by: Al Viro --- fs/ncpfs/dir.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'fs/ncpfs') diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 81c287d105d..9c51f621e90 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -1144,8 +1144,16 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry, old_dentry->d_parent->d_name.name, old_dentry->d_name.name, new_dentry->d_parent->d_name.name, new_dentry->d_name.name); - if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) + if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode)) { + /* + * fail with EBUSY if there are still references to this + * directory. + */ dentry_unhash(new_dentry); + error = -EBUSY; + if (!d_unhashed(new_dentry)) + goto out; + } ncp_age_dentry(server, old_dentry); ncp_age_dentry(server, new_dentry); -- cgit v1.2.3