aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/alpha/kernel/osf_sys.c8
-rw-r--r--arch/parisc/hpux/sys_hpux.c10
-rw-r--r--fs/cachefiles/bind.c2
-rw-r--r--fs/cachefiles/daemon.c6
-rw-r--r--fs/compat.c10
-rw-r--r--fs/ecryptfs/super.c6
-rw-r--r--fs/nfsd/nfs4xdr.c6
-rw-r--r--fs/nfsd/vfs.c10
-rw-r--r--fs/statfs.c50
-rw-r--r--include/linux/fs.h3
-rw-r--r--kernel/acct.c2
11 files changed, 67 insertions, 46 deletions
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index de9d39717808..88131c6e42e3 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -234,11 +234,11 @@ linux_to_osf_statfs(struct kstatfs *linux_stat, struct osf_statfs __user *osf_st
234} 234}
235 235
236static int 236static int
237do_osf_statfs(struct dentry * dentry, struct osf_statfs __user *buffer, 237do_osf_statfs(struct path *path, struct osf_statfs __user *buffer,
238 unsigned long bufsiz) 238 unsigned long bufsiz)
239{ 239{
240 struct kstatfs linux_stat; 240 struct kstatfs linux_stat;
241 int error = vfs_statfs(dentry, &linux_stat); 241 int error = vfs_statfs(path, &linux_stat);
242 if (!error) 242 if (!error)
243 error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz); 243 error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
244 return error; 244 return error;
@@ -252,7 +252,7 @@ SYSCALL_DEFINE3(osf_statfs, char __user *, pathname,
252 252
253 retval = user_path(pathname, &path); 253 retval = user_path(pathname, &path);
254 if (!retval) { 254 if (!retval) {
255 retval = do_osf_statfs(path.dentry, buffer, bufsiz); 255 retval = do_osf_statfs(&path buffer, bufsiz);
256 path_put(&path); 256 path_put(&path);
257 } 257 }
258 return retval; 258 return retval;
@@ -267,7 +267,7 @@ SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd,
267 retval = -EBADF; 267 retval = -EBADF;
268 file = fget(fd); 268 file = fget(fd);
269 if (file) { 269 if (file) {
270 retval = do_osf_statfs(file->f_path.dentry, buffer, bufsiz); 270 retval = do_osf_statfs(&file->f_path, buffer, bufsiz);
271 fput(file); 271 fput(file);
272 } 272 }
273 return retval; 273 return retval;
diff --git a/arch/parisc/hpux/sys_hpux.c b/arch/parisc/hpux/sys_hpux.c
index 92343bd35fa3..ba430a03bc7a 100644
--- a/arch/parisc/hpux/sys_hpux.c
+++ b/arch/parisc/hpux/sys_hpux.c
@@ -145,7 +145,7 @@ static int hpux_ustat(dev_t dev, struct hpux_ustat __user *ubuf)
145 s = user_get_super(dev); 145 s = user_get_super(dev);
146 if (s == NULL) 146 if (s == NULL)
147 goto out; 147 goto out;
148 err = vfs_statfs(s->s_root, &sbuf); 148 err = statfs_by_dentry(s->s_root, &sbuf);
149 drop_super(s); 149 drop_super(s);
150 if (err) 150 if (err)
151 goto out; 151 goto out;
@@ -186,12 +186,12 @@ struct hpux_statfs {
186 int16_t f_pad; 186 int16_t f_pad;
187}; 187};
188 188
189static int vfs_statfs_hpux(struct dentry *dentry, struct hpux_statfs *buf) 189static int do_statfs_hpux(struct path *path, struct hpux_statfs *buf)
190{ 190{
191 struct kstatfs st; 191 struct kstatfs st;
192 int retval; 192 int retval;
193 193
194 retval = vfs_statfs(dentry, &st); 194 retval = vfs_statfs(path, &st);
195 if (retval) 195 if (retval)
196 return retval; 196 return retval;
197 197
@@ -219,7 +219,7 @@ asmlinkage long hpux_statfs(const char __user *pathname,
219 error = user_path(pathname, &path); 219 error = user_path(pathname, &path);
220 if (!error) { 220 if (!error) {
221 struct hpux_statfs tmp; 221 struct hpux_statfs tmp;
222 error = vfs_statfs_hpux(path.dentry, &tmp); 222 error = do_statfs_hpux(&path, &tmp);
223 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 223 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
224 error = -EFAULT; 224 error = -EFAULT;
225 path_put(&path); 225 path_put(&path);
@@ -237,7 +237,7 @@ asmlinkage long hpux_fstatfs(unsigned int fd, struct hpux_statfs __user * buf)
237 file = fget(fd); 237 file = fget(fd);
238 if (!file) 238 if (!file)
239 goto out; 239 goto out;
240 error = vfs_statfs_hpux(file->f_path.dentry, &tmp); 240 error = do_statfs_hpux(&file->f_path, &tmp);
241 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 241 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
242 error = -EFAULT; 242 error = -EFAULT;
243 fput(file); 243 fput(file);
diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
index 2906077ac798..a2603e7c0bb5 100644
--- a/fs/cachefiles/bind.c
+++ b/fs/cachefiles/bind.c
@@ -146,7 +146,7 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
146 goto error_unsupported; 146 goto error_unsupported;
147 147
148 /* get the cache size and blocksize */ 148 /* get the cache size and blocksize */
149 ret = vfs_statfs(root, &stats); 149 ret = vfs_statfs(&path, &stats);
150 if (ret < 0) 150 if (ret < 0)
151 goto error_unsupported; 151 goto error_unsupported;
152 152
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index c2413561ea75..24eb0d37241a 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -683,6 +683,10 @@ int cachefiles_has_space(struct cachefiles_cache *cache,
683 unsigned fnr, unsigned bnr) 683 unsigned fnr, unsigned bnr)
684{ 684{
685 struct kstatfs stats; 685 struct kstatfs stats;
686 struct path path = {
687 .mnt = cache->mnt,
688 .dentry = cache->mnt->mnt_root,
689 };
686 int ret; 690 int ret;
687 691
688 //_enter("{%llu,%llu,%llu,%llu,%llu,%llu},%u,%u", 692 //_enter("{%llu,%llu,%llu,%llu,%llu,%llu},%u,%u",
@@ -697,7 +701,7 @@ int cachefiles_has_space(struct cachefiles_cache *cache,
697 /* find out how many pages of blockdev are available */ 701 /* find out how many pages of blockdev are available */
698 memset(&stats, 0, sizeof(stats)); 702 memset(&stats, 0, sizeof(stats));
699 703
700 ret = vfs_statfs(cache->mnt->mnt_root, &stats); 704 ret = vfs_statfs(&path, &stats);
701 if (ret < 0) { 705 if (ret < 0) {
702 if (ret == -EIO) 706 if (ret == -EIO)
703 cachefiles_io_error(cache, "statfs failed"); 707 cachefiles_io_error(cache, "statfs failed");
diff --git a/fs/compat.c b/fs/compat.c
index 6490d2134ff3..fc6c2adf2f6b 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -266,7 +266,7 @@ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_sta
266 error = user_path(pathname, &path); 266 error = user_path(pathname, &path);
267 if (!error) { 267 if (!error) {
268 struct kstatfs tmp; 268 struct kstatfs tmp;
269 error = vfs_statfs(path.dentry, &tmp); 269 error = vfs_statfs(&path, &tmp);
270 if (!error) 270 if (!error)
271 error = put_compat_statfs(buf, &tmp); 271 error = put_compat_statfs(buf, &tmp);
272 path_put(&path); 272 path_put(&path);
@@ -284,7 +284,7 @@ asmlinkage long compat_sys_fstatfs(unsigned int fd, struct compat_statfs __user
284 file = fget(fd); 284 file = fget(fd);
285 if (!file) 285 if (!file)
286 goto out; 286 goto out;
287 error = vfs_statfs(file->f_path.dentry, &tmp); 287 error = vfs_statfs(&file->f_path, &tmp);
288 if (!error) 288 if (!error)
289 error = put_compat_statfs(buf, &tmp); 289 error = put_compat_statfs(buf, &tmp);
290 fput(file); 290 fput(file);
@@ -334,7 +334,7 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t s
334 error = user_path(pathname, &path); 334 error = user_path(pathname, &path);
335 if (!error) { 335 if (!error) {
336 struct kstatfs tmp; 336 struct kstatfs tmp;
337 error = vfs_statfs(path.dentry, &tmp); 337 error = vfs_statfs(&path, &tmp);
338 if (!error) 338 if (!error)
339 error = put_compat_statfs64(buf, &tmp); 339 error = put_compat_statfs64(buf, &tmp);
340 path_put(&path); 340 path_put(&path);
@@ -355,7 +355,7 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c
355 file = fget(fd); 355 file = fget(fd);
356 if (!file) 356 if (!file)
357 goto out; 357 goto out;
358 error = vfs_statfs(file->f_path.dentry, &tmp); 358 error = vfs_statfs(&file->f_path, &tmp);
359 if (!error) 359 if (!error)
360 error = put_compat_statfs64(buf, &tmp); 360 error = put_compat_statfs64(buf, &tmp);
361 fput(file); 361 fput(file);
@@ -378,7 +378,7 @@ asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u)
378 sb = user_get_super(new_decode_dev(dev)); 378 sb = user_get_super(new_decode_dev(dev));
379 if (!sb) 379 if (!sb)
380 return -EINVAL; 380 return -EINVAL;
381 err = vfs_statfs(sb->s_root, &sbuf); 381 err = statfs_by_dentry(sb->s_root, &sbuf);
382 drop_super(sb); 382 drop_super(sb);
383 if (err) 383 if (err)
384 return err; 384 return err;
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c
index 4b5de6c6e0fa..f7fc286a3aa9 100644
--- a/fs/ecryptfs/super.c
+++ b/fs/ecryptfs/super.c
@@ -118,7 +118,11 @@ void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode)
118 */ 118 */
119static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf) 119static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf)
120{ 120{
121 return vfs_statfs(ecryptfs_dentry_to_lower(dentry), buf); 121 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
122
123 if (!lower_dentry->d_sb->s_op->statfs)
124 return -ENOSYS;
125 return lower_dentry->d_sb->s_op->statfs(lower_dentry, buf);
122} 126}
123 127
124/** 128/**
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index ac17a7080239..4d6154f66e04 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1756,6 +1756,10 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
1756 struct nfs4_acl *acl = NULL; 1756 struct nfs4_acl *acl = NULL;
1757 struct nfsd4_compoundres *resp = rqstp->rq_resp; 1757 struct nfsd4_compoundres *resp = rqstp->rq_resp;
1758 u32 minorversion = resp->cstate.minorversion; 1758 u32 minorversion = resp->cstate.minorversion;
1759 struct path path = {
1760 .mnt = exp->ex_path.mnt,
1761 .dentry = dentry,
1762 };
1759 1763
1760 BUG_ON(bmval1 & NFSD_WRITEONLY_ATTRS_WORD1); 1764 BUG_ON(bmval1 & NFSD_WRITEONLY_ATTRS_WORD1);
1761 BUG_ON(bmval0 & ~nfsd_suppattrs0(minorversion)); 1765 BUG_ON(bmval0 & ~nfsd_suppattrs0(minorversion));
@@ -1776,7 +1780,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
1776 FATTR4_WORD0_MAXNAME)) || 1780 FATTR4_WORD0_MAXNAME)) ||
1777 (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | 1781 (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE |
1778 FATTR4_WORD1_SPACE_TOTAL))) { 1782 FATTR4_WORD1_SPACE_TOTAL))) {
1779 err = vfs_statfs(dentry, &statfs); 1783 err = vfs_statfs(&path, &statfs);
1780 if (err) 1784 if (err)
1781 goto out_nfserr; 1785 goto out_nfserr;
1782 } 1786 }
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 3c111120b619..f6f1a718642f 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -2019,8 +2019,14 @@ out:
2019__be32 2019__be32
2020nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat, int access) 2020nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat, int access)
2021{ 2021{
2022 __be32 err = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP | access); 2022 struct path path = {
2023 if (!err && vfs_statfs(fhp->fh_dentry,stat)) 2023 .mnt = fhp->fh_export->ex_path.mnt,
2024 .dentry = fhp->fh_dentry,
2025 };
2026 __be32 err;
2027
2028 err = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP | access);
2029 if (!err && vfs_statfs(&path, stat))
2024 err = nfserr_io; 2030 err = nfserr_io;
2025 return err; 2031 return err;
2026} 2032}
diff --git a/fs/statfs.c b/fs/statfs.c
index 4ef021f3b612..6a305709a4da 100644
--- a/fs/statfs.c
+++ b/fs/statfs.c
@@ -7,33 +7,35 @@
7#include <linux/security.h> 7#include <linux/security.h>
8#include <linux/uaccess.h> 8#include <linux/uaccess.h>
9 9
10int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) 10int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
11{ 11{
12 int retval = -ENODEV; 12 int retval;
13 13
14 if (dentry) { 14 if (!dentry->d_sb->s_op->statfs)
15 retval = -ENOSYS; 15 return -ENOSYS;
16 if (dentry->d_sb->s_op->statfs) { 16
17 memset(buf, 0, sizeof(*buf)); 17 memset(buf, 0, sizeof(*buf));
18 retval = security_sb_statfs(dentry); 18 retval = security_sb_statfs(dentry);
19 if (retval) 19 if (retval)
20 return retval; 20 return retval;
21 retval = dentry->d_sb->s_op->statfs(dentry, buf); 21 retval = dentry->d_sb->s_op->statfs(dentry, buf);
22 if (retval == 0 && buf->f_frsize == 0) 22 if (retval == 0 && buf->f_frsize == 0)
23 buf->f_frsize = buf->f_bsize; 23 buf->f_frsize = buf->f_bsize;
24 }
25 }
26 return retval; 24 return retval;
27} 25}
28 26
27int vfs_statfs(struct path *path, struct kstatfs *buf)
28{
29 return statfs_by_dentry(path->dentry, buf);
30}
29EXPORT_SYMBOL(vfs_statfs); 31EXPORT_SYMBOL(vfs_statfs);
30 32
31static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf) 33static int do_statfs_native(struct path *path, struct statfs *buf)
32{ 34{
33 struct kstatfs st; 35 struct kstatfs st;
34 int retval; 36 int retval;
35 37
36 retval = vfs_statfs(dentry, &st); 38 retval = vfs_statfs(path, &st);
37 if (retval) 39 if (retval)
38 return retval; 40 return retval;
39 41
@@ -72,12 +74,12 @@ static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf)
72 return 0; 74 return 0;
73} 75}
74 76
75static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf) 77static int do_statfs64(struct path *path, struct statfs64 *buf)
76{ 78{
77 struct kstatfs st; 79 struct kstatfs st;
78 int retval; 80 int retval;
79 81
80 retval = vfs_statfs(dentry, &st); 82 retval = vfs_statfs(path, &st);
81 if (retval) 83 if (retval)
82 return retval; 84 return retval;
83 85
@@ -107,7 +109,7 @@ SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct statfs __user *, b
107 error = user_path(pathname, &path); 109 error = user_path(pathname, &path);
108 if (!error) { 110 if (!error) {
109 struct statfs tmp; 111 struct statfs tmp;
110 error = vfs_statfs_native(path.dentry, &tmp); 112 error = do_statfs_native(&path, &tmp);
111 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 113 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
112 error = -EFAULT; 114 error = -EFAULT;
113 path_put(&path); 115 path_put(&path);
@@ -125,7 +127,7 @@ SYSCALL_DEFINE3(statfs64, const char __user *, pathname, size_t, sz, struct stat
125 error = user_path(pathname, &path); 127 error = user_path(pathname, &path);
126 if (!error) { 128 if (!error) {
127 struct statfs64 tmp; 129 struct statfs64 tmp;
128 error = vfs_statfs64(path.dentry, &tmp); 130 error = do_statfs64(&path, &tmp);
129 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 131 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
130 error = -EFAULT; 132 error = -EFAULT;
131 path_put(&path); 133 path_put(&path);
@@ -143,7 +145,7 @@ SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct statfs __user *, buf)
143 file = fget(fd); 145 file = fget(fd);
144 if (!file) 146 if (!file)
145 goto out; 147 goto out;
146 error = vfs_statfs_native(file->f_path.dentry, &tmp); 148 error = do_statfs_native(&file->f_path, &tmp);
147 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 149 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
148 error = -EFAULT; 150 error = -EFAULT;
149 fput(file); 151 fput(file);
@@ -164,7 +166,7 @@ SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user
164 file = fget(fd); 166 file = fget(fd);
165 if (!file) 167 if (!file)
166 goto out; 168 goto out;
167 error = vfs_statfs64(file->f_path.dentry, &tmp); 169 error = do_statfs64(&file->f_path, &tmp);
168 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 170 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
169 error = -EFAULT; 171 error = -EFAULT;
170 fput(file); 172 fput(file);
@@ -183,7 +185,7 @@ SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
183 if (!s) 185 if (!s)
184 return -EINVAL; 186 return -EINVAL;
185 187
186 err = vfs_statfs(s->s_root, &sbuf); 188 err = statfs_by_dentry(s->s_root, &sbuf);
187 drop_super(s); 189 drop_super(s);
188 if (err) 190 if (err)
189 return err; 191 return err;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index dec9ac598859..9bedf4219f83 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1813,7 +1813,8 @@ extern struct vfsmount *collect_mounts(struct path *);
1813extern void drop_collected_mounts(struct vfsmount *); 1813extern void drop_collected_mounts(struct vfsmount *);
1814extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, 1814extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
1815 struct vfsmount *); 1815 struct vfsmount *);
1816extern int vfs_statfs(struct dentry *, struct kstatfs *); 1816extern int vfs_statfs(struct path *, struct kstatfs *);
1817extern int statfs_by_dentry(struct dentry *, struct kstatfs *);
1817extern int freeze_super(struct super_block *super); 1818extern int freeze_super(struct super_block *super);
1818extern int thaw_super(struct super_block *super); 1819extern int thaw_super(struct super_block *super);
1819 1820
diff --git a/kernel/acct.c b/kernel/acct.c
index 385b88461c29..fa7eb3de2ddc 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -122,7 +122,7 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file)
122 spin_unlock(&acct_lock); 122 spin_unlock(&acct_lock);
123 123
124 /* May block */ 124 /* May block */
125 if (vfs_statfs(file->f_path.dentry, &sbuf)) 125 if (vfs_statfs(&file->f_path, &sbuf))
126 return res; 126 return res;
127 suspend = sbuf.f_blocks * SUSPEND; 127 suspend = sbuf.f_blocks * SUSPEND;
128 resume = sbuf.f_blocks * RESUME; 128 resume = sbuf.f_blocks * RESUME;