mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel@redhat.com, linux-kernel@vger.kernel.org
Cc: Steven Whitehouse <swhiteho@redhat.com>
Subject: [PATCH 08/19] GFS2: Clean up reservation removal
Date: Mon,  4 Nov 2013 11:09:31 +0000	[thread overview]
Message-ID: <1383563382-8535-9-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1383563382-8535-1-git-send-email-swhiteho@redhat.com>

The reservation for an inode should be cleared when it is truncated so
that we can start again at a different offset for future allocations.
We could try and do better than that, by resetting the search based on
where the truncation started from, but this is only a first step.

In addition, there are three callers of gfs2_rs_delete() but only one
of those should really be testing the value of i_writecount. While
we get away with that in the other cases currently, I think it would
be better if we made that test specific to the one case which
requires it.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 62a65fc..21ad0f1 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1279,6 +1279,7 @@ do_grow_qunlock:
 
 int gfs2_setattr_size(struct inode *inode, u64 newsize)
 {
+	struct gfs2_inode *ip = GFS2_I(inode);
 	int ret;
 	u64 oldsize;
 
@@ -1294,7 +1295,7 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
 
 	inode_dio_wait(inode);
 
-	ret = gfs2_rs_alloc(GFS2_I(inode));
+	ret = gfs2_rs_alloc(ip);
 	if (ret)
 		goto out;
 
@@ -1304,6 +1305,7 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
 		goto out;
 	}
 
+	gfs2_rs_deltree(ip->i_res);
 	ret = do_shrink(inode, oldsize, newsize);
 out:
 	put_write_access(inode);
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 0621b46..9ad20ed 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -620,7 +620,7 @@ static int gfs2_release(struct inode *inode, struct file *file)
 	if (!(file->f_mode & FMODE_WRITE))
 		return 0;
 
-	gfs2_rs_delete(ip);
+	gfs2_rs_delete(ip, &inode->i_writecount);
 	return 0;
 }
 
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index cd58611..4b79c19 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -711,7 +711,7 @@ fail_gunlock2:
 fail_free_inode:
 	if (ip->i_gl)
 		gfs2_glock_put(ip->i_gl);
-	gfs2_rs_delete(ip);
+	gfs2_rs_delete(ip, NULL);
 	free_inode_nonrcu(inode);
 	inode = NULL;
 fail_gunlock:
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 285dd36..d4d10fa 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -661,14 +661,13 @@ void gfs2_rs_deltree(struct gfs2_blkreserv *rs)
 /**
  * gfs2_rs_delete - delete a multi-block reservation
  * @ip: The inode for this reservation
+ * @wcount: The inode's write count, or NULL
  *
  */
-void gfs2_rs_delete(struct gfs2_inode *ip)
+void gfs2_rs_delete(struct gfs2_inode *ip, atomic_t *wcount)
 {
-	struct inode *inode = &ip->i_inode;
-
 	down_write(&ip->i_rw_mutex);
-	if (ip->i_res && atomic_read(&inode->i_writecount) <= 1) {
+	if (ip->i_res && ((wcount == NULL) || (atomic_read(wcount) <= 1))) {
 		gfs2_rs_deltree(ip->i_res);
 		BUG_ON(ip->i_res->rs_free);
 		kmem_cache_free(gfs2_rsrv_cachep, ip->i_res);
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
index 5b3f4a8..57ea16b 100644
--- a/fs/gfs2/rgrp.h
+++ b/fs/gfs2/rgrp.h
@@ -48,7 +48,7 @@ extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
 
 extern int gfs2_rs_alloc(struct gfs2_inode *ip);
 extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs);
-extern void gfs2_rs_delete(struct gfs2_inode *ip);
+extern void gfs2_rs_delete(struct gfs2_inode *ip, atomic_t *wcount);
 extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta);
 extern void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen);
 extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip);
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index e5639de..35da5b1 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1526,7 +1526,7 @@ out_unlock:
 out:
 	/* Case 3 starts here */
 	truncate_inode_pages(&inode->i_data, 0);
-	gfs2_rs_delete(ip);
+	gfs2_rs_delete(ip, NULL);
 	gfs2_ordered_del_inode(ip);
 	clear_inode(inode);
 	gfs2_dir_hash_inval(ip);
-- 
1.7.4.4


  parent reply	other threads:[~2013-11-04 11:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-04 11:09 GFS2: Pre-pull patch posting (merge window) Steven Whitehouse
2013-11-04 11:09 ` [PATCH 01/19] GFS2: d_splice_alias() can't return error Steven Whitehouse
2013-11-04 11:09 ` [PATCH 02/19] GFS2: optimize rbm_from_block wrt bi_start Steven Whitehouse
2013-11-04 11:09 ` [PATCH 03/19] GFS2: introduce bi_blocks for optimization Steven Whitehouse
2013-11-04 11:09 ` [PATCH 04/19] GFS2: Do not reset flags on active reservations Steven Whitehouse
2013-11-04 11:09 ` [PATCH 05/19] GFS2: Introduce rbm field bii Steven Whitehouse
2013-11-04 11:09 ` [PATCH 06/19] GFS2: new function gfs2_rbm_incr Steven Whitehouse
2013-11-04 11:09 ` [PATCH 07/19] GFS2: fix dentry leaks Steven Whitehouse
2013-11-04 11:09 ` Steven Whitehouse [this message]
2013-11-04 11:09 ` [PATCH 09/19] GFS2: Add allocation parameters structure Steven Whitehouse
2013-11-04 11:09 ` [PATCH 10/19] GFS2: Speed up starting point selection for block allocation Steven Whitehouse
2013-11-04 11:09 ` [PATCH 11/19] GFS2: Move gfs2_icbit_munge into quota.c Steven Whitehouse
2013-11-04 11:09 ` [PATCH 12/19] GFS2: Remove obsolete quota tunable Steven Whitehouse
2013-11-04 11:09 ` [PATCH 13/19] GFS2: Make two similar quota code fragments into a function Steven Whitehouse
2013-11-04 11:09 ` [PATCH 14/19] GFS2: Inline qd_trylock into gfs2_quota_unlock Steven Whitehouse
2013-11-04 11:09 ` [PATCH 15/19] GFS2: Protect quota sync generation Steven Whitehouse
2013-11-04 11:09 ` [PATCH 16/19] GFS2: Use lockref for glocks Steven Whitehouse
2013-11-04 11:22 ` [PATCH 17/19] GFS2: Use reflink for quota data cache Steven Whitehouse
2013-11-04 11:22   ` [PATCH 18/19] GFS2: Rename quota qd_lru_lock qd_lock Steven Whitehouse
2013-11-04 11:22   ` [PATCH 19/19] GFS2: Use generic list_lru for quota Steven Whitehouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383563382-8535-9-git-send-email-swhiteho@redhat.com \
    --to=swhiteho@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome