Skip to content

Commit 759bfee

Browse files
Christoph Hellwigjankara
authored andcommitted
dquot: move dquot transfer responsibility into the filesystem
Currently notify_change calls vfs_dq_transfer directly. This means we tie the quota code into the VFS. Get rid of that and make the filesystem responsible for the transfer. Most filesystems already do this, only ufs and udf need the code added, and for jfs it needs to be enabled unconditionally instead of only when ACLs are enabled. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 63936dd commit 759bfee

8 files changed

Lines changed: 65 additions & 38 deletions

File tree

fs/attr.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <linux/capability.h>
1313
#include <linux/fsnotify.h>
1414
#include <linux/fcntl.h>
15-
#include <linux/quotaops.h>
1615
#include <linux/security.h>
1716

1817
/* Taken over from the old code... */
@@ -212,14 +211,8 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
212211
error = inode->i_op->setattr(dentry, attr);
213212
} else {
214213
error = inode_change_ok(inode, attr);
215-
if (!error) {
216-
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
217-
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
218-
error = vfs_dq_transfer(inode, attr) ?
219-
-EDQUOT : 0;
220-
if (!error)
221-
error = inode_setattr(inode, attr);
222-
}
214+
if (!error)
215+
error = inode_setattr(inode, attr);
223216
}
224217

225218
if (ia_valid & ATTR_SIZE)

fs/jfs/acl.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include <linux/sched.h>
2222
#include <linux/fs.h>
23-
#include <linux/quotaops.h>
2423
#include <linux/posix_acl_xattr.h>
2524
#include "jfs_incore.h"
2625
#include "jfs_txnmgr.h"
@@ -174,7 +173,7 @@ int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
174173
return rc;
175174
}
176175

177-
static int jfs_acl_chmod(struct inode *inode)
176+
int jfs_acl_chmod(struct inode *inode)
178177
{
179178
struct posix_acl *acl, *clone;
180179
int rc;
@@ -205,26 +204,3 @@ static int jfs_acl_chmod(struct inode *inode)
205204
posix_acl_release(clone);
206205
return rc;
207206
}
208-
209-
int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
210-
{
211-
struct inode *inode = dentry->d_inode;
212-
int rc;
213-
214-
rc = inode_change_ok(inode, iattr);
215-
if (rc)
216-
return rc;
217-
218-
if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
219-
(iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
220-
if (vfs_dq_transfer(inode, iattr))
221-
return -EDQUOT;
222-
}
223-
224-
rc = inode_setattr(inode, iattr);
225-
226-
if (!rc && (iattr->ia_valid & ATTR_MODE))
227-
rc = jfs_acl_chmod(inode);
228-
229-
return rc;
230-
}

fs/jfs/file.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include <linux/fs.h>
21+
#include <linux/quotaops.h>
2122
#include "jfs_incore.h"
2223
#include "jfs_inode.h"
2324
#include "jfs_dmap.h"
@@ -88,14 +89,37 @@ static int jfs_release(struct inode *inode, struct file *file)
8889
return 0;
8990
}
9091

92+
int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
93+
{
94+
struct inode *inode = dentry->d_inode;
95+
int rc;
96+
97+
rc = inode_change_ok(inode, iattr);
98+
if (rc)
99+
return rc;
100+
101+
if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
102+
(iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
103+
if (vfs_dq_transfer(inode, iattr))
104+
return -EDQUOT;
105+
}
106+
107+
rc = inode_setattr(inode, iattr);
108+
109+
if (!rc && (iattr->ia_valid & ATTR_MODE))
110+
rc = jfs_acl_chmod(inode);
111+
112+
return rc;
113+
}
114+
91115
const struct inode_operations jfs_file_inode_operations = {
92116
.truncate = jfs_truncate,
93117
.setxattr = jfs_setxattr,
94118
.getxattr = jfs_getxattr,
95119
.listxattr = jfs_listxattr,
96120
.removexattr = jfs_removexattr,
97-
#ifdef CONFIG_JFS_POSIX_ACL
98121
.setattr = jfs_setattr,
122+
#ifdef CONFIG_JFS_POSIX_ACL
99123
.check_acl = jfs_check_acl,
100124
#endif
101125
};

fs/jfs/jfs_acl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
int jfs_check_acl(struct inode *, int);
2424
int jfs_init_acl(tid_t, struct inode *, struct inode *);
25-
int jfs_setattr(struct dentry *, struct iattr *);
25+
int jfs_acl_chmod(struct inode *inode);
2626

2727
#else
2828

@@ -32,5 +32,10 @@ static inline int jfs_init_acl(tid_t tid, struct inode *inode,
3232
return 0;
3333
}
3434

35+
static inline int jfs_acl_chmod(struct inode *inode)
36+
{
37+
return 0;
38+
}
39+
3540
#endif
3641
#endif /* _H_JFS_ACL */

fs/jfs/jfs_inode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4040
int fh_len, int fh_type);
4141
extern void jfs_set_inode_flags(struct inode *);
4242
extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
43+
extern int jfs_setattr(struct dentry *, struct iattr *);
4344

4445
extern const struct address_space_operations jfs_aops;
4546
extern const struct inode_operations jfs_dir_inode_operations;

fs/jfs/namei.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,8 +1541,8 @@ const struct inode_operations jfs_dir_inode_operations = {
15411541
.getxattr = jfs_getxattr,
15421542
.listxattr = jfs_listxattr,
15431543
.removexattr = jfs_removexattr,
1544-
#ifdef CONFIG_JFS_POSIX_ACL
15451544
.setattr = jfs_setattr,
1545+
#ifdef CONFIG_JFS_POSIX_ACL
15461546
.check_acl = jfs_check_acl,
15471547
#endif
15481548
};

fs/udf/file.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/errno.h>
3535
#include <linux/smp_lock.h>
3636
#include <linux/pagemap.h>
37+
#include <linux/quotaops.h>
3738
#include <linux/buffer_head.h>
3839
#include <linux/aio.h>
3940

@@ -217,6 +218,26 @@ const struct file_operations udf_file_operations = {
217218
.llseek = generic_file_llseek,
218219
};
219220

221+
static int udf_setattr(struct dentry *dentry, struct iattr *iattr)
222+
{
223+
struct inode *inode = dentry->d_inode;
224+
int error;
225+
226+
error = inode_change_ok(inode, iattr);
227+
if (error)
228+
return error;
229+
230+
if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
231+
(iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
232+
error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0;
233+
if (error)
234+
return error;
235+
}
236+
237+
return inode_setattr(inode, iattr);
238+
}
239+
220240
const struct inode_operations udf_file_inode_operations = {
221-
.truncate = udf_truncate,
241+
.truncate = udf_truncate,
242+
.setattr = udf_setattr,
222243
};

fs/ufs/truncate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <linux/buffer_head.h>
4545
#include <linux/blkdev.h>
4646
#include <linux/sched.h>
47+
#include <linux/quotaops.h>
4748

4849
#include "ufs_fs.h"
4950
#include "ufs.h"
@@ -517,6 +518,12 @@ static int ufs_setattr(struct dentry *dentry, struct iattr *attr)
517518
if (error)
518519
return error;
519520

521+
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
522+
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
523+
error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
524+
if (error)
525+
return error;
526+
}
520527
if (ia_valid & ATTR_SIZE &&
521528
attr->ia_size != i_size_read(inode)) {
522529
loff_t old_i_size = inode->i_size;

0 commit comments

Comments
 (0)