Skip to contentSkip to conversation

Fix bz 224480, pass on the baton for unlinked, but open inodes

Cluster-devel Steven Whitehouse 3 participants 3 messages Mar 12, 2007 – Mar 13, 2007 GFS2 file system

lore
Share & tools
lore
#0 lore raw

Hi,

This is my current patch to fix bz 224480 which survives my torture test of setting the drop_count too low and then running postmark. It needs wider testing though as it makes a number of changes to the demote code.

This patch removes the memory allocation which was previously required in order to queue a demotion request on a glock. This was mentioned in bz 221152 as a future objective. Also, this then allows the use of the GLF_DEMOTE flag in GFS2's new ->drop_inode() routine to clear the link count on the inode (the callback only occurs if another node tries to demote the iopen glock for the inode, and this only happens in the case that the link count has hit zero). This ensures that inodes which are open, but otherwise with zero link count cannot get "lost" unless a node crashes (in which case we have another method of recovering the free space).

Steve.

fs/gfs2/acl.c +0 -0
fs/gfs2/bmap.c +0 -0
fs/gfs2/daemon.c +0 -0
fs/gfs2/dir.c +0 -0
fs/gfs2/eaops.c +0 -0
fs/gfs2/eattr.c +0 -0
fs/gfs2/glock.c +56 -171

350 lines not on this page · raw message

fs/gfs2/glock.h +1 -1
index d7cef74..5e662ea 100644
@@ -67,7 +67,7 @@ static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl)
 {
 	int ret;
 	spin_lock(&gl->gl_spin);
-	ret = !list_empty(&gl->gl_waiters2) || !list_empty(&gl->gl_waiters3);
+	ret = test_bit(GLF_DEMOTE, &gl->gl_flags) || !list_empty(&gl->gl_waiters3);
 	spin_unlock(&gl->gl_spin);
 	return ret;
 }
fs/gfs2/glops.c +0 -0
fs/gfs2/incore.h +3 -5
index 7555261..9c12582 100644
@@ -115,11 +115,8 @@ enum {
 	/* Actions */
 	HIF_MUTEX		= 0,
 	HIF_PROMOTE		= 1,
-	HIF_DEMOTE		= 2,
 
 	/* States */
-	HIF_ALLOCED		= 4,
-	HIF_DEALLOC		= 5,
 	HIF_HOLDER		= 6,
 	HIF_FIRST		= 7,
 	HIF_ABORTED		= 9,
@@ -142,8 +139,8 @@ struct gfs2_holder {
 enum {
 	GLF_LOCK		= 1,
 	GLF_STICKY		= 2,
+	GLF_DEMOTE		= 3,
 	GLF_DIRTY		= 5,
-	GLF_SKIP_WAITERS2	= 6,
 };
 
 struct gfs2_glock {
@@ -156,11 +153,12 @@ struct gfs2_glock {
 
 	unsigned int gl_state;
 	unsigned int gl_hash;
+	unsigned int gl_demote_state; /* state requested by remote node */
+	unsigned long gl_demote_time; /* time of first demote request */
 	struct task_struct *gl_owner;
 	unsigned long gl_ip;
 	struct list_head gl_holders;
 	struct list_head gl_waiters1;	/* HIF_MUTEX */
-	struct list_head gl_waiters2;	/* HIF_DEMOTE */
 	struct list_head gl_waiters3;	/* HIF_PROMOTE */
 
 	const struct gfs2_glock_operations *gl_ops;
fs/gfs2/inode.c +0 -0
fs/gfs2/lm.c +0 -0
fs/gfs2/locking.c +0 -0
fs/gfs2/log.c +0 -0
fs/gfs2/lops.c +0 -0
fs/gfs2/main.c +0 -1
index 2183953..c4bb374 100644
@@ -45,7 +45,6 @@ static void gfs2_init_glock_once(void *foo, struct kmem_cache *cachep, unsigned
 		spin_lock_init(&gl->gl_spin);
 		INIT_LIST_HEAD(&gl->gl_holders);
 		INIT_LIST_HEAD(&gl->gl_waiters1);
-		INIT_LIST_HEAD(&gl->gl_waiters2);
 		INIT_LIST_HEAD(&gl->gl_waiters3);
 		gl->gl_lvb = NULL;
 		atomic_set(&gl->gl_lvb_count, 0);
fs/gfs2/meta_io.c +0 -0
fs/gfs2/mount.c +0 -0
fs/gfs2/ondisk.c +0 -0
fs/gfs2/ops_address.c +0 -0
fs/gfs2/ops_dentry.c +0 -0
fs/gfs2/ops_export.c +0 -0
fs/gfs2/ops_file.c +0 -0
fs/gfs2/ops_fstype.c +0 -0
fs/gfs2/ops_inode.c +0 -0
fs/gfs2/ops_super.c +27 -1
index b89999d..485ce3d 100644
@@ -284,6 +284,31 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
 }
 
 /**
+ * gfs2_drop_inode - Drop an inode (test for remote unlink)
+ * @inode: The inode to drop
+ *
+ * If we've received a callback on an iopen lock then its because a
+ * remote node tried to deallocate the inode but failed due to this node
+ * still having the inode open. Here we mark the link count zero
+ * since we know that it must have reached zero if the GLF_DEMOTE flag
+ * is set on the iopen glock. If we didn't do a disk read since the
+ * remote node removed the final link then we might otherwise miss
+ * this event. This check ensures that this node will deallocate the
+ * inode's blocks, or alternatively pass the baton on to another
+ * node for later deallocation.
+ */
+static void gfs2_drop_inode(struct inode *inode)
+{
+	if (inode->i_private && inode->i_nlink) {
+		struct gfs2_inode *ip = GFS2_I(inode);
+		struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
+		if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags))
+			clear_nlink(inode);
+	}
+	generic_drop_inode(inode);
+}
+
+/**
  * gfs2_clear_inode - Deallocate an inode when VFS is done with it
  * @inode: The VFS inode
  *
@@ -441,7 +466,7 @@ out_unlock:
 out_uninit:
 	gfs2_holder_uninit(&ip->i_iopen_gh);
 	gfs2_glock_dq_uninit(&gh);
-	if (error)
+	if (error && error != GLR_TRYFAILED)
 		fs_warn(sdp, "gfs2_delete_inode: %d\n", error);
 out:
 	truncate_inode_pages(&inode->i_data, 0);
@@ -481,6 +506,7 @@ const struct super_operations gfs2_super_ops = {
 	.statfs			= gfs2_statfs,
 	.remount_fs		= gfs2_remount_fs,
 	.clear_inode		= gfs2_clear_inode,
+	.drop_inode		= gfs2_drop_inode,
 	.show_options		= gfs2_show_options,
 };
 
fs/gfs2/ops_vm.c +0 -0
fs/gfs2/quota.c +0 -0
fs/gfs2/recovery.c +0 -0
fs/gfs2/rgrp.c +0 -0
fs/gfs2/super.c +0 -0
fs/gfs2/sys.c +0 -0
fs/gfs2/trans.c +0 -0
fs/gfs2/util.c +0 -0
#1 lore raw
Quoted 6 lines · Steven Whitehouse

Hi,

This is my current patch to fix bz 224480 which survives my torture test of setting the drop_count too low and then running postmark. It needs wider testing though as it makes a number of changes to the demote code.

Quoted 11 lines

This patch removes the memory allocation which was previously required in order to queue a demotion request on a glock. This was mentioned in bz 221152 as a future objective. Also, this then allows the use of the GLF_DEMOTE flag in GFS2's new ->drop_inode() routine to clear the link count on the inode (the callback only occurs if another node tries to demote the iopen glock for the inode, and this only happens in the case that the link count has hit zero). This ensures that inodes which are open, but otherwise with zero link count cannot get "lost" unless a node crashes (in which case we have another method of recovering the free space).

I've been running this patch while doing other testing and trying to track down other problems and I haven't seen any issues, so ACK.

Josef

#2 lore raw
Quoted 23 lines · Josef Whiter
Quoted 6 lines · Steven Whitehouse

Hi,

This is my current patch to fix bz 224480 which survives my torture test of setting the drop_count too low and then running postmark. It needs wider testing though as it makes a number of changes to the demote code.

Quoted 13 lines

This patch removes the memory allocation which was previously required in order to queue a demotion request on a glock. This was mentioned in bz 221152 as a future objective. Also, this then allows the use of the GLF_DEMOTE flag in GFS2's new ->drop_inode() routine to clear the link count on the inode (the callback only occurs if another node tries to demote the iopen glock for the inode, and this only happens in the case that the link count has hit zero). This ensures that inodes which are open, but otherwise with zero link count cannot get "lost" unless a node crashes (in which case we have another method of recovering the free space).

Quoted 6 lines

I've been running this patch while doing other testing and trying to track down other problems and I haven't seen any issues, so ACK.

I do believe your testing efforts and have no doubts about Steve's technical skills. However, some of previous patches showed we took in patches liberally without any form of technical review. Wrong approaches could shift bugs into subtle and/or difficult to fix states. The scale of this particular patch is non-trivial. Let's have a real review first.

-- Wendy