diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-05-06 17:04:58 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-05-21 13:30:43 -0400 |
commit | b9b2dd36c1bc64430f8e13990ab135cbecc10076 (patch) | |
tree | 051bb6a238c9ff98fe135de3e8591c65cf242d46 | |
parent | 0636c73ee7b129f77f577aaaefc8dde057be6d18 (diff) |
quota: unify ->get_dqblk
Pass the larger struct fs_disk_quota to the ->get_dqblk operation so
that the Q_GETQUOTA and Q_XGETQUOTA operations can be implemented
with a single filesystem operation and we can retire the ->get_xquota
operation. The additional information (RT-subvolume accounting and
warn counts) are left zero for the VFS quota implementation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | fs/gfs2/quota.c | 6 | ||||
-rw-r--r-- | fs/quota/dquot.c | 27 | ||||
-rw-r--r-- | fs/quota/quota.c | 23 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_quotaops.c | 4 | ||||
-rw-r--r-- | include/linux/quota.h | 3 | ||||
-rw-r--r-- | include/linux/quotaops.h | 3 |
6 files changed, 42 insertions, 24 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index d5f4661287f9..dec93577a783 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -1476,8 +1476,8 @@ static int gfs2_quota_get_xstate(struct super_block *sb, | |||
1476 | return 0; | 1476 | return 0; |
1477 | } | 1477 | } |
1478 | 1478 | ||
1479 | static int gfs2_xquota_get(struct super_block *sb, int type, qid_t id, | 1479 | static int gfs2_get_dqblk(struct super_block *sb, int type, qid_t id, |
1480 | struct fs_disk_quota *fdq) | 1480 | struct fs_disk_quota *fdq) |
1481 | { | 1481 | { |
1482 | struct gfs2_sbd *sdp = sb->s_fs_info; | 1482 | struct gfs2_sbd *sdp = sb->s_fs_info; |
1483 | struct gfs2_quota_lvb *qlvb; | 1483 | struct gfs2_quota_lvb *qlvb; |
@@ -1629,7 +1629,7 @@ out_put: | |||
1629 | const struct quotactl_ops gfs2_quotactl_ops = { | 1629 | const struct quotactl_ops gfs2_quotactl_ops = { |
1630 | .quota_sync = gfs2_quota_sync, | 1630 | .quota_sync = gfs2_quota_sync, |
1631 | .get_xstate = gfs2_quota_get_xstate, | 1631 | .get_xstate = gfs2_quota_get_xstate, |
1632 | .get_xquota = gfs2_xquota_get, | 1632 | .get_dqblk = gfs2_get_dqblk, |
1633 | .set_xquota = gfs2_xquota_set, | 1633 | .set_xquota = gfs2_xquota_set, |
1634 | }; | 1634 | }; |
1635 | 1635 | ||
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 01347e81d0ca..6aed77fc99c7 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -2301,25 +2301,30 @@ static inline qsize_t stoqb(qsize_t space) | |||
2301 | } | 2301 | } |
2302 | 2302 | ||
2303 | /* Generic routine for getting common part of quota structure */ | 2303 | /* Generic routine for getting common part of quota structure */ |
2304 | static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di) | 2304 | static void do_get_dqblk(struct dquot *dquot, struct fs_disk_quota *di) |
2305 | { | 2305 | { |
2306 | struct mem_dqblk *dm = &dquot->dq_dqb; | 2306 | struct mem_dqblk *dm = &dquot->dq_dqb; |
2307 | 2307 | ||
2308 | memset(di, 0, sizeof(*di)); | ||
2309 | di->d_version = FS_DQUOT_VERSION; | ||
2310 | di->d_flags = dquot->dq_type == USRQUOTA ? | ||
2311 | XFS_USER_QUOTA : XFS_GROUP_QUOTA; | ||
2312 | di->d_id = dquot->dq_id; | ||
2313 | |||
2308 | spin_lock(&dq_data_lock); | 2314 | spin_lock(&dq_data_lock); |
2309 | di->dqb_bhardlimit = stoqb(dm->dqb_bhardlimit); | 2315 | di->d_blk_hardlimit = stoqb(dm->dqb_bhardlimit); |
2310 | di->dqb_bsoftlimit = stoqb(dm->dqb_bsoftlimit); | 2316 | di->d_blk_softlimit = stoqb(dm->dqb_bsoftlimit); |
2311 | di->dqb_curspace = dm->dqb_curspace + dm->dqb_rsvspace; | 2317 | di->d_ino_hardlimit = dm->dqb_ihardlimit; |
2312 | di->dqb_ihardlimit = dm->dqb_ihardlimit; | 2318 | di->d_ino_softlimit = dm->dqb_isoftlimit; |
2313 | di->dqb_isoftlimit = dm->dqb_isoftlimit; | 2319 | di->d_bcount = dm->dqb_curspace + dm->dqb_rsvspace; |
2314 | di->dqb_curinodes = dm->dqb_curinodes; | 2320 | di->d_icount = dm->dqb_curinodes; |
2315 | di->dqb_btime = dm->dqb_btime; | 2321 | di->d_btimer = dm->dqb_btime; |
2316 | di->dqb_itime = dm->dqb_itime; | 2322 | di->d_itimer = dm->dqb_itime; |
2317 | di->dqb_valid = QIF_ALL; | ||
2318 | spin_unlock(&dq_data_lock); | 2323 | spin_unlock(&dq_data_lock); |
2319 | } | 2324 | } |
2320 | 2325 | ||
2321 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, | 2326 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, |
2322 | struct if_dqblk *di) | 2327 | struct fs_disk_quota *di) |
2323 | { | 2328 | { |
2324 | struct dquot *dquot; | 2329 | struct dquot *dquot; |
2325 | 2330 | ||
diff --git a/fs/quota/quota.c b/fs/quota/quota.c index 95388f9b7356..8680e257c2bd 100644 --- a/fs/quota/quota.c +++ b/fs/quota/quota.c | |||
@@ -136,19 +136,32 @@ static int quota_setinfo(struct super_block *sb, int type, void __user *addr) | |||
136 | return sb->s_qcop->set_info(sb, type, &info); | 136 | return sb->s_qcop->set_info(sb, type, &info); |
137 | } | 137 | } |
138 | 138 | ||
139 | static void copy_to_if_dqblk(struct if_dqblk *dst, struct fs_disk_quota *src) | ||
140 | { | ||
141 | dst->dqb_bhardlimit = src->d_blk_hardlimit; | ||
142 | dst->dqb_bsoftlimit = src->d_blk_softlimit; | ||
143 | dst->dqb_curspace = src->d_bcount; | ||
144 | dst->dqb_ihardlimit = src->d_ino_hardlimit; | ||
145 | dst->dqb_isoftlimit = src->d_ino_softlimit; | ||
146 | dst->dqb_curinodes = src->d_icount; | ||
147 | dst->dqb_btime = src->d_btimer; | ||
148 | dst->dqb_itime = src->d_itimer; | ||
149 | dst->dqb_valid = QIF_ALL; | ||
150 | } | ||
151 | |||
139 | static int quota_getquota(struct super_block *sb, int type, qid_t id, | 152 | static int quota_getquota(struct super_block *sb, int type, qid_t id, |
140 | void __user *addr) | 153 | void __user *addr) |
141 | { | 154 | { |
155 | struct fs_disk_quota fdq; | ||
142 | struct if_dqblk idq; | 156 | struct if_dqblk idq; |
143 | int ret; | 157 | int ret; |
144 | 158 | ||
145 | if (!sb_has_quota_active(sb, type)) | ||
146 | return -ESRCH; | ||
147 | if (!sb->s_qcop->get_dqblk) | 159 | if (!sb->s_qcop->get_dqblk) |
148 | return -ENOSYS; | 160 | return -ENOSYS; |
149 | ret = sb->s_qcop->get_dqblk(sb, type, id, &idq); | 161 | ret = sb->s_qcop->get_dqblk(sb, type, id, &fdq); |
150 | if (ret) | 162 | if (ret) |
151 | return ret; | 163 | return ret; |
164 | copy_to_if_dqblk(&idq, &fdq); | ||
152 | if (copy_to_user(addr, &idq, sizeof(idq))) | 165 | if (copy_to_user(addr, &idq, sizeof(idq))) |
153 | return -EFAULT; | 166 | return -EFAULT; |
154 | return 0; | 167 | return 0; |
@@ -210,9 +223,9 @@ static int quota_getxquota(struct super_block *sb, int type, qid_t id, | |||
210 | struct fs_disk_quota fdq; | 223 | struct fs_disk_quota fdq; |
211 | int ret; | 224 | int ret; |
212 | 225 | ||
213 | if (!sb->s_qcop->get_xquota) | 226 | if (!sb->s_qcop->get_dqblk) |
214 | return -ENOSYS; | 227 | return -ENOSYS; |
215 | ret = sb->s_qcop->get_xquota(sb, type, id, &fdq); | 228 | ret = sb->s_qcop->get_dqblk(sb, type, id, &fdq); |
216 | if (!ret && copy_to_user(addr, &fdq, sizeof(fdq))) | 229 | if (!ret && copy_to_user(addr, &fdq, sizeof(fdq))) |
217 | return -EFAULT; | 230 | return -EFAULT; |
218 | return ret; | 231 | return ret; |
diff --git a/fs/xfs/linux-2.6/xfs_quotaops.c b/fs/xfs/linux-2.6/xfs_quotaops.c index 1947514ce1ad..3d473f43c9a9 100644 --- a/fs/xfs/linux-2.6/xfs_quotaops.c +++ b/fs/xfs/linux-2.6/xfs_quotaops.c | |||
@@ -97,7 +97,7 @@ xfs_fs_set_xstate( | |||
97 | } | 97 | } |
98 | 98 | ||
99 | STATIC int | 99 | STATIC int |
100 | xfs_fs_get_xquota( | 100 | xfs_fs_get_dqblk( |
101 | struct super_block *sb, | 101 | struct super_block *sb, |
102 | int type, | 102 | int type, |
103 | qid_t id, | 103 | qid_t id, |
@@ -135,6 +135,6 @@ xfs_fs_set_xquota( | |||
135 | const struct quotactl_ops xfs_quotactl_operations = { | 135 | const struct quotactl_ops xfs_quotactl_operations = { |
136 | .get_xstate = xfs_fs_get_xstate, | 136 | .get_xstate = xfs_fs_get_xstate, |
137 | .set_xstate = xfs_fs_set_xstate, | 137 | .set_xstate = xfs_fs_set_xstate, |
138 | .get_xquota = xfs_fs_get_xquota, | 138 | .get_dqblk = xfs_fs_get_dqblk, |
139 | .set_xquota = xfs_fs_set_xquota, | 139 | .set_xquota = xfs_fs_set_xquota, |
140 | }; | 140 | }; |
diff --git a/include/linux/quota.h b/include/linux/quota.h index cdfde10481b7..42364219dc9b 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h | |||
@@ -337,11 +337,10 @@ struct quotactl_ops { | |||
337 | int (*quota_sync)(struct super_block *, int, int); | 337 | int (*quota_sync)(struct super_block *, int, int); |
338 | int (*get_info)(struct super_block *, int, struct if_dqinfo *); | 338 | int (*get_info)(struct super_block *, int, struct if_dqinfo *); |
339 | int (*set_info)(struct super_block *, int, struct if_dqinfo *); | 339 | int (*set_info)(struct super_block *, int, struct if_dqinfo *); |
340 | int (*get_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *); | 340 | int (*get_dqblk)(struct super_block *, int, qid_t, struct fs_disk_quota *); |
341 | int (*set_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *); | 341 | int (*set_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *); |
342 | int (*get_xstate)(struct super_block *, struct fs_quota_stat *); | 342 | int (*get_xstate)(struct super_block *, struct fs_quota_stat *); |
343 | int (*set_xstate)(struct super_block *, unsigned int, int); | 343 | int (*set_xstate)(struct super_block *, unsigned int, int); |
344 | int (*get_xquota)(struct super_block *, int, qid_t, struct fs_disk_quota *); | ||
345 | int (*set_xquota)(struct super_block *, int, qid_t, struct fs_disk_quota *); | 344 | int (*set_xquota)(struct super_block *, int, qid_t, struct fs_disk_quota *); |
346 | }; | 345 | }; |
347 | 346 | ||
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index e6fa7acce290..d32a48631b0d 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
@@ -63,7 +63,8 @@ int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); | |||
63 | int vfs_quota_sync(struct super_block *sb, int type, int wait); | 63 | int vfs_quota_sync(struct super_block *sb, int type, int wait); |
64 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 64 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
65 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 65 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
66 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); | 66 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, |
67 | struct fs_disk_quota *di); | ||
67 | int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); | 68 | int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); |
68 | 69 | ||
69 | int dquot_transfer(struct inode *inode, struct iattr *iattr); | 70 | int dquot_transfer(struct inode *inode, struct iattr *iattr); |