aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/quota.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-06-14 15:32:57 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2006-06-14 15:32:57 -0400
commitfeaa7bba026c181ce071d5a4884f7f9dd26207a1 (patch)
treec858deb225917265cb07820730e9764674d133e8 /fs/gfs2/quota.c
parent22da645fd6675b7abc55cf937ddf6132f343e5b9 (diff)
[GFS2] Fix unlinked file handling
This patch fixes the way we have been dealing with unlinked, but still open files. It removes all limits (other than memory for inodes, as per every other filesystem) on numbers of these which we can support on GFS2. It also means that (like other fs) its the responsibility of the last process to close the file to deallocate the storage, rather than the person who did the unlinking. Note that with GFS2, those two events might take place on different nodes. Also there are a number of other changes: o We use the Linux inode subsystem as it was intended to be used, wrt allocating GFS2 inodes o The Linux inode cache is now the point which we use for local enforcement of only holding one copy of the inode in core at once (previous to this we used the glock layer). o We no longer use the unlinked "special" file. We just ignore it completely. This makes unlinking more efficient. o We now use the 4th block allocation state. The previously unused state is used to track unlinked but still open inodes. o gfs2_inoded is no longer needed o Several fields are now no longer needed (and removed) from the in core struct gfs2_inode o Several fields are no longer needed (and removed) from the in core superblock There are a number of future possible optimisations and clean ups which have been made possible by this patch. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/quota.c')
-rw-r--r--fs/gfs2/quota.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index f752b0184690..d3cd5171d7c7 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -248,7 +248,7 @@ static void slot_put(struct gfs2_quota_data *qd)
248static int bh_get(struct gfs2_quota_data *qd) 248static int bh_get(struct gfs2_quota_data *qd)
249{ 249{
250 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; 250 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
251 struct gfs2_inode *ip = sdp->sd_qc_inode->u.generic_ip; 251 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode);
252 unsigned int block, offset; 252 unsigned int block, offset;
253 uint64_t dblock; 253 uint64_t dblock;
254 int new = 0; 254 int new = 0;
@@ -266,7 +266,7 @@ static int bh_get(struct gfs2_quota_data *qd)
266 block = qd->qd_slot / sdp->sd_qc_per_block; 266 block = qd->qd_slot / sdp->sd_qc_per_block;
267 offset = qd->qd_slot % sdp->sd_qc_per_block;; 267 offset = qd->qd_slot % sdp->sd_qc_per_block;;
268 268
269 error = gfs2_block_map(ip->i_vnode, block, &new, &dblock, &boundary); 269 error = gfs2_block_map(&ip->i_inode, block, &new, &dblock, &boundary);
270 if (error) 270 if (error)
271 goto fail; 271 goto fail;
272 error = gfs2_meta_read(ip->i_gl, dblock, DIO_START | DIO_WAIT, &bh); 272 error = gfs2_meta_read(ip->i_gl, dblock, DIO_START | DIO_WAIT, &bh);
@@ -444,7 +444,7 @@ static void qdsb_put(struct gfs2_quota_data *qd)
444 444
445int gfs2_quota_hold(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) 445int gfs2_quota_hold(struct gfs2_inode *ip, uint32_t uid, uint32_t gid)
446{ 446{
447 struct gfs2_sbd *sdp = ip->i_sbd; 447 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
448 struct gfs2_alloc *al = &ip->i_alloc; 448 struct gfs2_alloc *al = &ip->i_alloc;
449 struct gfs2_quota_data **qd = al->al_qd; 449 struct gfs2_quota_data **qd = al->al_qd;
450 int error; 450 int error;
@@ -493,7 +493,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, uint32_t uid, uint32_t gid)
493 493
494void gfs2_quota_unhold(struct gfs2_inode *ip) 494void gfs2_quota_unhold(struct gfs2_inode *ip)
495{ 495{
496 struct gfs2_sbd *sdp = ip->i_sbd; 496 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
497 struct gfs2_alloc *al = &ip->i_alloc; 497 struct gfs2_alloc *al = &ip->i_alloc;
498 unsigned int x; 498 unsigned int x;
499 499
@@ -531,7 +531,7 @@ static int sort_qd(const void *a, const void *b)
531static void do_qc(struct gfs2_quota_data *qd, int64_t change) 531static void do_qc(struct gfs2_quota_data *qd, int64_t change)
532{ 532{
533 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; 533 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
534 struct gfs2_inode *ip = sdp->sd_qc_inode->u.generic_ip; 534 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode);
535 struct gfs2_quota_change *qc = qd->qd_bh_qc; 535 struct gfs2_quota_change *qc = qd->qd_bh_qc;
536 int64_t x; 536 int64_t x;
537 537
@@ -578,7 +578,7 @@ static void do_qc(struct gfs2_quota_data *qd, int64_t change)
578static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, 578static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc,
579 int64_t change, struct gfs2_quota_data *qd) 579 int64_t change, struct gfs2_quota_data *qd)
580{ 580{
581 struct inode *inode = ip->i_vnode; 581 struct inode *inode = &ip->i_inode;
582 struct address_space *mapping = inode->i_mapping; 582 struct address_space *mapping = inode->i_mapping;
583 unsigned long index = loc >> PAGE_CACHE_SHIFT; 583 unsigned long index = loc >> PAGE_CACHE_SHIFT;
584 unsigned offset = loc & (PAGE_CACHE_SHIFT - 1); 584 unsigned offset = loc & (PAGE_CACHE_SHIFT - 1);
@@ -647,7 +647,7 @@ unlock:
647static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) 647static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
648{ 648{
649 struct gfs2_sbd *sdp = (*qda)->qd_gl->gl_sbd; 649 struct gfs2_sbd *sdp = (*qda)->qd_gl->gl_sbd;
650 struct gfs2_inode *ip = sdp->sd_quota_inode->u.generic_ip; 650 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode);
651 unsigned int data_blocks, ind_blocks; 651 unsigned int data_blocks, ind_blocks;
652 struct file_ra_state ra_state; 652 struct file_ra_state ra_state;
653 struct gfs2_holder *ghs, i_gh; 653 struct gfs2_holder *ghs, i_gh;
@@ -716,7 +716,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
716 goto out_gunlock; 716 goto out_gunlock;
717 } 717 }
718 718
719 file_ra_state_init(&ra_state, ip->i_vnode->i_mapping); 719 file_ra_state_init(&ra_state, ip->i_inode.i_mapping);
720 for (x = 0; x < num_qd; x++) { 720 for (x = 0; x < num_qd; x++) {
721 qd = qda[x]; 721 qd = qda[x];
722 offset = qd2offset(qd); 722 offset = qd2offset(qd);
@@ -758,7 +758,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,
758 struct gfs2_holder *q_gh) 758 struct gfs2_holder *q_gh)
759{ 759{
760 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; 760 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
761 struct gfs2_inode *ip = sdp->sd_quota_inode->u.generic_ip; 761 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode);
762 struct gfs2_holder i_gh; 762 struct gfs2_holder i_gh;
763 struct gfs2_quota q; 763 struct gfs2_quota q;
764 char buf[sizeof(struct gfs2_quota)]; 764 char buf[sizeof(struct gfs2_quota)];
@@ -829,7 +829,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,
829 829
830int gfs2_quota_lock(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) 830int gfs2_quota_lock(struct gfs2_inode *ip, uint32_t uid, uint32_t gid)
831{ 831{
832 struct gfs2_sbd *sdp = ip->i_sbd; 832 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
833 struct gfs2_alloc *al = &ip->i_alloc; 833 struct gfs2_alloc *al = &ip->i_alloc;
834 unsigned int x; 834 unsigned int x;
835 int error = 0; 835 int error = 0;
@@ -958,7 +958,7 @@ static int print_message(struct gfs2_quota_data *qd, char *type)
958 958
959int gfs2_quota_check(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) 959int gfs2_quota_check(struct gfs2_inode *ip, uint32_t uid, uint32_t gid)
960{ 960{
961 struct gfs2_sbd *sdp = ip->i_sbd; 961 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
962 struct gfs2_alloc *al = &ip->i_alloc; 962 struct gfs2_alloc *al = &ip->i_alloc;
963 struct gfs2_quota_data *qd; 963 struct gfs2_quota_data *qd;
964 int64_t value; 964 int64_t value;
@@ -1008,7 +1008,7 @@ void gfs2_quota_change(struct gfs2_inode *ip, int64_t change,
1008 unsigned int x; 1008 unsigned int x;
1009 unsigned int found = 0; 1009 unsigned int found = 0;
1010 1010
1011 if (gfs2_assert_warn(ip->i_sbd, change)) 1011 if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), change))
1012 return; 1012 return;
1013 if (ip->i_di.di_flags & GFS2_DIF_SYSTEM) 1013 if (ip->i_di.di_flags & GFS2_DIF_SYSTEM)
1014 return; 1014 return;
@@ -1126,7 +1126,7 @@ int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id,
1126 1126
1127int gfs2_quota_init(struct gfs2_sbd *sdp) 1127int gfs2_quota_init(struct gfs2_sbd *sdp)
1128{ 1128{
1129 struct gfs2_inode *ip = sdp->sd_qc_inode->u.generic_ip; 1129 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode);
1130 unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; 1130 unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift;
1131 unsigned int x, slot = 0; 1131 unsigned int x, slot = 0;
1132 unsigned int found = 0; 1132 unsigned int found = 0;
@@ -1162,7 +1162,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
1162 1162
1163 if (!extlen) { 1163 if (!extlen) {
1164 int new = 0; 1164 int new = 0;
1165 error = gfs2_extent_map(ip->i_vnode, x, &new, &dblock, &extlen); 1165 error = gfs2_extent_map(&ip->i_inode, x, &new, &dblock, &extlen);
1166 if (error) 1166 if (error)
1167 goto fail; 1167 goto fail;
1168 } 1168 }