Skip to contentSkip to conversation

GFS2: Core locking interface

PATCH In review Steven Whitehouse 3 participants 7 messages Aug 31, 2006 – Sep 4, 2006 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 2/16 GFS2: Core locking interface

[PATCH 02/16] GFS2: Core locking interface

The core GFS2 locking code, including the interface to the pluggable locking modules.

 fs/gfs2/glock.c        | 2254 +++++++++++++++++++++++++++++++++++++++++++++++++
 fs/gfs2/glock.h        |  151 +++
 fs/gfs2/lm.c           |  244 +++++
 fs/gfs2/lm.h           |   41 
 fs/gfs2/lm_interface.h |  290 ++++++
 fs/gfs2/locking.c      |  191 ++++
 6 files changed, 3171 insertions(+)
fs/gfs2/lm.c new file +244 -0
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
+ * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/completion.h>
+#include <linux/buffer_head.h>
+#include <linux/delay.h>
+#include <linux/gfs2_ondisk.h>
+
+#include "gfs2.h"
+#include "lm_interface.h"
+#include "incore.h"
+#include "glock.h"
+#include "lm.h"
+#include "super.h"
+#include "util.h"
+#include "lvb.h"
+
+/**
+ * gfs2_lm_mount - mount a locking protocol
+ * @sdp: the filesystem
+ * @args: mount arguements
+ * @silent: if 1, don't complain if the FS isn't a GFS2 fs
+ *
+ * Returns: errno
+ */
+
+int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)
+{
+	char *proto = sdp->sd_proto_name;
+	char *table = sdp->sd_table_name;
+	int flags = 0;
+	int error;
+
+	if (sdp->sd_args.ar_spectator)
+		flags |= LM_MFLAG_SPECTATOR;
+
+	fs_info(sdp, "Trying to join cluster \"%s\", \"%s\"\n", proto, table);
+
+	error = gfs2_mount_lockproto(proto, table, sdp->sd_args.ar_hostdata,
+				     gfs2_glock_cb, sdp,
+				     GFS2_MIN_LVB_SIZE, flags,
+				     &sdp->sd_lockstruct, &sdp->sd_kobj);
+	if (error) {
+		fs_info(sdp, "can't mount proto=%s, table=%s, hostdata=%s\n",
+			proto, table, sdp->sd_args.ar_hostdata);
+		goto out;
+	}
+
+	if (gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lockspace) ||
+	    gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_ops) ||
+	    gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lvb_size >=
+				  GFS2_MIN_LVB_SIZE)) {
+		gfs2_unmount_lockproto(&sdp->sd_lockstruct);
+		goto out;
+	}
+
+	if (sdp->sd_args.ar_spectator)
+		snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.s", table);
+	else
+		snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.%u", table,
+			 sdp->sd_lockstruct.ls_jid);
+
+	fs_info(sdp, "Joined cluster. Now mounting FS...\n");
+
+	if ((sdp->sd_lockstruct.ls_flags & LM_LSFLAG_LOCAL) &&
+	    !sdp->sd_args.ar_ignore_local_fs) {
+		sdp->sd_args.ar_localflocks = 1;
+		sdp->sd_args.ar_localcaching = 1;
+	}
+
+ out:
+	return error;
+}
+
+void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		sdp->sd_lockstruct.ls_ops->lm_others_may_mount(
+					sdp->sd_lockstruct.ls_lockspace);
+}
+
+void gfs2_lm_unmount(struct gfs2_sbd *sdp)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		gfs2_unmount_lockproto(&sdp->sd_lockstruct);
+}
+
+int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...)
+{
+	va_list args;
+
+	if (test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags))
+		return 0;
+
+	va_start(args, fmt);
+	vprintk(fmt, args);
+	va_end(args);
+
+	fs_err(sdp, "about to withdraw from the cluster\n");
+	BUG_ON(sdp->sd_args.ar_debug);
+	
+
+	fs_err(sdp, "waiting for outstanding I/O\n");
+
+	/* FIXME: suspend dm device so oustanding bio's complete
+	   and all further io requests fail */
+
+	fs_err(sdp, "telling LM to withdraw\n");
+	gfs2_withdraw_lockproto(&sdp->sd_lockstruct);
+	fs_err(sdp, "withdrawn\n");
+	dump_stack();
+
+	return -1;
+}
+
+int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+		     lm_lock_t **lockp)
+{
+	int error;
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		error = -EIO;
+	else
+		error = sdp->sd_lockstruct.ls_ops->lm_get_lock(
+				sdp->sd_lockstruct.ls_lockspace, name, lockp);
+	return error;
+}
+
+void gfs2_lm_put_lock(struct gfs2_sbd *sdp, lm_lock_t *lock)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		sdp->sd_lockstruct.ls_ops->lm_put_lock(lock);
+}
+
+unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock,
+			  unsigned int cur_state, unsigned int req_state,
+			  unsigned int flags)
+{
+	int ret;
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		ret = 0;
+	else
+		ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock,
+							 cur_state,
+							 req_state, flags);
+	return ret;
+}
+
+unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock,
+			    unsigned int cur_state)
+{
+	int ret;
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		ret = 0;
+	else
+		ret =  sdp->sd_lockstruct.ls_ops->lm_unlock(lock, cur_state);
+	return ret;
+}
+
+void gfs2_lm_cancel(struct gfs2_sbd *sdp, lm_lock_t *lock)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		sdp->sd_lockstruct.ls_ops->lm_cancel(lock);
+}
+
+int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp)
+{
+	int error;
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		error = -EIO;
+	else
+		error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp);
+	return error;
+}
+
+void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(lock, lvb);
+}
+
+#if 0
+void gfs2_lm_sync_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		sdp->sd_lockstruct.ls_ops->lm_sync_lvb(lock, lvb);
+}
+#endif  /*  0  */
+
+int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name,
+		      struct file *file, struct file_lock *fl)
+{
+	int error;
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		error = -EIO;
+	else
+		error = sdp->sd_lockstruct.ls_ops->lm_plock_get(
+			sdp->sd_lockstruct.ls_lockspace,
+			name, file, fl);
+	return error;
+}
+
+int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+		  struct file *file, int cmd, struct file_lock *fl)
+{
+	int error;
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		error = -EIO;
+	else
+		error = sdp->sd_lockstruct.ls_ops->lm_plock(
+			sdp->sd_lockstruct.ls_lockspace,
+			name, file, cmd, fl);
+	return error;
+}
+
+int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+		    struct file *file, struct file_lock *fl)
+{
+	int error;
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		error = -EIO;
+	else
+		error = sdp->sd_lockstruct.ls_ops->lm_punlock(
+			sdp->sd_lockstruct.ls_lockspace,
+			name, file, fl);
+	return error;
+}
+
+void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid,
+			   unsigned int message)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		sdp->sd_lockstruct.ls_ops->lm_recovery_done(
+			sdp->sd_lockstruct.ls_lockspace, jid, message);
+}
+
fs/gfs2/lm.h new file +41 -0

41 lines not on this page · raw message

fs/gfs2/locking.c new file +191 -0

191 lines not on this page · raw message

fs/gfs2/lm_interface.h new file +290 -0

290 lines not on this page · raw message

fs/gfs2/glock.c new file +2254 -0

2,234 lines not on this page · raw message

fs/gfs2/glock.h new file +151 -0

151 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 2 lines

+void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp)

I think this could be 'const struct gfs2_sbd *sdp'. Also in other places, const would probably be adequate.

Quoted 1 line

+void gfs2_lm_unmount(struct gfs2_sbd *sdp)

Like here

Quoted 1 line

+int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...)

And here.

fs/gfs2/lm.c line 115

Quoted 2 lines
fs/gfs2/lm.c new file +2 -0
+	/* FIXME: suspend dm device so oustanding bio's complete
+	   and all further io requests fail */

Would you like to fix them beforehand? :)

fs/gfs2/lm.c line 135

Quoted 11 lines
fs/gfs2/lm.c new file +11 -0
+int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+		     lm_lock_t **lockp)
+{
+	int error;
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		error = -EIO;
+	else
+		error = sdp->sd_lockstruct.ls_ops->lm_get_lock(
+				sdp->sd_lockstruct.ls_lockspace, name, lockp);
+	return error;
+}

How about

{
    int err = -EIO;
    if(likely(!test_bit(...)))
        err = sdp->...
    return err;
}?

Same applies for other similar functions, like

fs/gfs2/lm.c line 174

Quoted 6 lines
fs/gfs2/lm.c new file +6 -0
+unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock,
+			  unsigned int cur_state, unsigned int req_state,
+			  unsigned int flags)
+unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock,
+			    unsigned int cur_state)
+int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp)

and others.

fs/gfs2/lm.c line 196

Quoted 7 lines
fs/gfs2/lm.c new file +7 -0
+#if 0
+void gfs2_lm_sync_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		sdp->sd_lockstruct.ls_ops->lm_sync_lvb(lock, lvb);
+}
+#endif  /*  0  */

If this is unused, can it be removed?

fs/gfs2/lm.h line 17

Quoted 2 lines
fs/gfs2/lm.h new file +2 -0
+int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...)
+__attribute__ ((format(printf, 2, 3)));

Possibly indent the 2nd line a little.

fs/gfs2/locking.c line 31

Quoted 2 lines
fs/gfs2/locking.c new file +2 -0
+static struct list_head lmh_list;
+static struct mutex lmh_lock;

Is it intended that these do not have an initializer?

fs/gfs2/locking.c line 187

Quoted 5 lines
fs/gfs2/locking.c new file +5 -0
+void __init gfs2_init_lmh(void)
+{
+	mutex_init(&lmh_lock);
+	INIT_LIST_HEAD(&lmh_list);
+}

I suppose so. If they were initialized statically, this function could possibly be dropped.

fs/gfs2/lm_interface.h line 20

Quoted 3 lines
fs/gfs2/lm_interface.h new file +3 -0
+typedef void lm_lockspace_t;
+typedef void lm_lock_t;
+typedef void lm_fsdata_t;

Try to avoid typedefs for
- simple types like these (int/void/etc.)
- structures

fs/gfs2/lm_interface.h line 23

Quoted 2 lines
fs/gfs2/lm_interface.h new file +2 -0
+typedef void (*lm_callback_t) (lm_fsdata_t *fsdata, unsigned int type,
+			       void *data);

(Function prototypes are ok for me, because writing it out everytime for functions with a lot of args is tedious. (For recursive type uses, typedefs are even necessary.))

fs/gfs2/glock.c line 845

Quoted 2 lines
fs/gfs2/glock.c new file +2 -0
+		if (ret & LM_OUT_CANCELED)
+			handle_callback(gl, LM_ST_UNLOCKED); /* Lame */

Hm.

fs/gfs2/glock.c line 873

Quoted 5 lines
fs/gfs2/glock.c new file +5 -0
+
+	} else {
+		if (gfs2_assert_withdraw(sdp, 0) == -1)
+			fs_err(sdp, "ret = 0x%.8X\n", ret);
+	}

If you want, you can drop the {}. In fact, this is just like a "else if(gfs2_assert..."

fs/gfs2/glock.c line 923

Quoted 5 lines
fs/gfs2/glock.c new file +5 -0
+	if (gl->gl_state == LM_ST_EXCLUSIVE) {
+		if (glops->go_sync)
+			glops->go_sync(gl,
+				       DIO_METADATA | DIO_DATA | DIO_RELEASE);
+	}

if(gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync != NULL)

    glops->go_sync(...)

You might want to &&-chain other if()s too, if the if-condition lines do not get too long. (Note that I am not trying to enforce CodingStyle at all, I am just giving hints how I would do it.)

fs/gfs2/glock.c line 1050

Quoted 10 lines
fs/gfs2/glock.c new file +10 -0
+	while (gl->gl_req_gh != gh &&
+	       !test_bit(HIF_HOLDER, &gh->gh_iflags) &&
+	       !list_empty(&gh->gh_list)) {
+		if (gl->gl_req_bh &&
+		    !(gl->gl_req_gh &&
+		      (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) {
+			spin_unlock(&gl->gl_spin);
+			gfs2_lm_cancel(gl->gl_sbd, gl->gl_lock);
+			msleep(100);
+			spin_lock(&gl->gl_spin);

I'd be a little uncomfortable with the indent scheme used here.

fs/gfs2/glock.c line 1082

Quoted 6 lines
fs/gfs2/glock.c new file +6 -0
+	if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) {
+		spin_lock(&gl->gl_spin);
+		if (gl->gl_req_gh != gh &&
+		    !test_bit(HIF_HOLDER, &gh->gh_iflags) &&
+		    !list_empty(&gh->gh_list)) {
+			list_del_init(&gh->gh_list);

.

Quoted 2 lines
fs/gfs2/glock.c new file +2 -0
+int gfs2_glock_nq(struct gfs2_holder *gh)
+{

...

fs/gfs2/glock.c line 1210

Quoted 4 lines
fs/gfs2/glock.c new file +4 -0
+	if (!(gh->gh_flags & GL_ASYNC)) {
+		error = glock_wait_internal(gh);
+		if (error == GLR_CANCELED) {
+			msleep(100);

msleep is a busy-waiter IIRC. Really want to do that - what about some schedulling?

Review

Quoted 2 lines
(quoted diff) +2 -0
+			borked = 1;
+			serious = error;

This got me a laugh :)

fs/gfs2/glock.h line 55

Quoted 4 lines
fs/gfs2/glock.h new file +4 -0
+static inline int gfs2_glock_is_held_excl(struct gfs2_glock *gl)
+{
+	return (gl->gl_state == LM_ST_EXCLUSIVE);
+}

No need for the ().

Quite a lot of code, phew!

Jan Engelhardt

#2 lore raw
Quoted 10 lines · Jan Engelhardt

I suppose so. If they were initialized statically, this function could possibly be dropped.

fs/gfs2/lm_interface.h line 20

Quoted 3 lines
fs/gfs2/lm_interface.h new file +3 -0
+typedef void lm_lockspace_t;
+typedef void lm_lock_t;
+typedef void lm_fsdata_t;

Try to avoid typedefs for
- simple types like these (int/void/etc.)
- structures

yeah. If we dont want to expose a type externally, we forward declare the structure, and pointers to it can then be used and passed around. That's also more type-safe (and obviously more readable) than a typedef to void.

Quoted 6 lines

fs/gfs2/glock.c line 1210

Quoted 3 lines
fs/gfs2/glock.c new file +3 -0
+		error = glock_wait_internal(gh);
+		if (error == GLR_CANCELED) {
+			msleep(100);

msleep is a busy-waiter IIRC. Really want to do that - what about some schedulling?

no. mdelay() is the busy-waiter - msleep() is scheduling based.

Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+			borked = 1;
+			serious = error;

This got me a laugh :)

me too - the hidden joys of code review :-)

Ingo

#3 lore raw
In reply to Jan Engelhardt

Hi,

Quoted 5 lines · Jan Engelhardt
Quoted 1 line

+void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp)

I think this could be 'const struct gfs2_sbd *sdp'. Also in other places, const would probably be adequate.

Quoted 8 lines
Quoted 1 line

+void gfs2_lm_unmount(struct gfs2_sbd *sdp)

Like here

Quoted 1 line

+int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...)

And here.

Unfortunately thats not possible as the struct gfs2_sbd is actually changed lower down the call chain, but only in the lock_dlm module.

Quoted 5 lines

fs/gfs2/lm.c line 115

Quoted 2 lines
fs/gfs2/lm.c new file +2 -0
+	/* FIXME: suspend dm device so oustanding bio's complete
+	   and all further io requests fail */

Would you like to fix them beforehand? :)

Well we have a patch that we've been discussing recently. The question has been how to avoid making GFS2 depend on dm. This function is not required for using GFS2 as a local filesystem at all, its only required for the cluster case and it allows for withdrawing a node gracefully without fencing it. Its not an essential feature, but a "nice to have" and it will probably be fixed up fairly shortly.

Quoted 14 lines

fs/gfs2/lm.c line 135

Quoted 11 lines
fs/gfs2/lm.c new file +11 -0
+int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name,
+		     lm_lock_t **lockp)
+{
+	int error;
+	if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		error = -EIO;
+	else
+		error = sdp->sd_lockstruct.ls_ops->lm_get_lock(
+				sdp->sd_lockstruct.ls_lockspace, name, lockp);
+	return error;
+}

How about

Quoted 8 lines
{
    int err = -EIO;
    if(likely(!test_bit(...)))
        err = sdp->...
    return err;
}?

Same applies for other similar functions, like

Ok, all changed now.

Quoted 9 lines

fs/gfs2/lm.c line 196

Quoted 7 lines
fs/gfs2/lm.c new file +7 -0
+#if 0
+void gfs2_lm_sync_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		sdp->sd_lockstruct.ls_ops->lm_sync_lvb(lock, lvb);
+}
+#endif  /*  0  */

If this is unused, can it be removed?

Yes, now done.

Quoted 11 lines

fs/gfs2/lm.h line 17

Quoted 3 lines
fs/gfs2/lm.h new file +2 -0
+int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...)
+__attribute__ ((format(printf, 2, 3)));

Possibly indent the 2nd line a little.

fs/gfs2/locking.c line 31

Quoted 2 lines
fs/gfs2/locking.c new file +2 -0
+static struct list_head lmh_list;
+static struct mutex lmh_lock;

Is it intended that these do not have an initializer?

Quoted 9 lines

fs/gfs2/locking.c line 187

Quoted 5 lines
fs/gfs2/locking.c new file +5 -0
+void __init gfs2_init_lmh(void)
+{
+	mutex_init(&lmh_lock);
+	INIT_LIST_HEAD(&lmh_list);
+}

I suppose so. If they were initialized statically, this function could possibly be dropped.

Ok. Now done.

Quoted 8 lines

fs/gfs2/lm_interface.h line 20

Quoted 3 lines
fs/gfs2/lm_interface.h new file +3 -0
+typedef void lm_lockspace_t;
+typedef void lm_lock_t;
+typedef void lm_fsdata_t;

Try to avoid typedefs for
- simple types like these (int/void/etc.)
- structures

I'll talk to Dave Teigland and we'll try and fix this shortly.

Quoted 7 lines

fs/gfs2/lm_interface.h line 23

Quoted 2 lines
fs/gfs2/lm_interface.h new file +2 -0
+typedef void (*lm_callback_t) (lm_fsdata_t *fsdata, unsigned int type,
+			       void *data);

(Function prototypes are ok for me, because writing it out everytime for functions with a lot of args is tedious. (For recursive type uses, typedefs are even necessary.))

Quoted 5 lines

fs/gfs2/glock.c line 845

Quoted 2 lines
fs/gfs2/glock.c new file +2 -0
+		if (ret & LM_OUT_CANCELED)
+			handle_callback(gl, LM_ST_UNLOCKED); /* Lame */

Hm.

I'm not sure what the comment is referring to - the code looks fine to me, so I've removed the comment since its confusing.

[various other style comments snipped]

The other changes you suggest have all be done in the latest patch:

http://www.kernel.org/git/?p=linux/kernel/git/steve/gfs2-2.6.git;a=commitdiff;h=5029996547a9f3988459e11955c13259495308ef

Quoted 4 lines
Quoted 3 lines
fs/gfs2/glock.c new file +2 -0
+int gfs2_glock_nq(struct gfs2_holder *gh)
+{

...

Quoted 8 lines

fs/gfs2/glock.c line 1210

Quoted 4 lines
fs/gfs2/glock.c new file +4 -0
+	if (!(gh->gh_flags & GL_ASYNC)) {
+		error = glock_wait_internal(gh);
+		if (error == GLR_CANCELED) {
+			msleep(100);

msleep is a busy-waiter IIRC. Really want to do that - what about some schedulling?

This very rarely happens, its on the failure path rather than something that you'd see during normal operation. As Ingo says, its a scheduling based wait. You could argue that we ought to use an exponential back-off rather than a fixed delay, but it seems to work fine in practice and has the advantage of being simple.

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+			borked = 1;
+			serious = error;

This got me a laugh :)

Well I think thats a Ken Preslan original variable name - I can't take credit for that one :-)

Quoted 8 lines

fs/gfs2/glock.h line 55

Quoted 4 lines
fs/gfs2/glock.h new file +4 -0
+static inline int gfs2_glock_is_held_excl(struct gfs2_glock *gl)
+{
+	return (gl->gl_state == LM_ST_EXCLUSIVE);
+}

No need for the ().

Quoted 4 lines

Quite a lot of code, phew!

Jan Engelhardt

The glock code is the largest single file in GFS2. I'm looking at ways of reducing that a bit over the medium term as I think that ought to be possible. The main thing which that requires is looking at how we deal with cached locks. I'd also like to use RCU for the glock hash table eventually as well,

Steve.

Signature · 1 line
VGER BF report: U 0.5
#4 lore raw

Hi,

Quoted 2 lines

Unfortunately thats not possible as the struct gfs2_sbd is actually changed lower down the call chain, but only in the lock_dlm module.

+void gfs2_lm_unmount(struct gfs2_sbd *sdp)
+{
+ if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+ gfs2_unmount_lockproto(&sdp->sd_lockstruct);
+}

I can't follow... test_bit does not modify *sdp or sdp->sd_flags, and gfs2_unmount_lockproto does not either.

Quoted 1 line

http://www.kernel.org/git/?p=linux/kernel/git/steve

/gfs2-2.6.git;a=commitdiff;h=5029996547a9f3988459e11955c13259495308ef

(Argh for browsers: while copy-and-paste from firefox to xterm compresses all spaces (like s/ +/ /g), MSIE displays it compressed right away. The latter is caused because it does not support the white-space:pre; CSS attribute. A workaround for both browsers is to s/ / &nbsp;/g)

Jan Engelhardt

Signature · 2 lines
-- 
VGER BF report: H 0.000814757
#5 lore raw

Hi,

Quoted 12 lines · Jan Engelhardt

Hi,

Quoted 2 lines

Unfortunately thats not possible as the struct gfs2_sbd is actually changed lower down the call chain, but only in the lock_dlm module.

fs/gfs2/lm.c new file +5 -0
+void gfs2_lm_unmount(struct gfs2_sbd *sdp)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		gfs2_unmount_lockproto(&sdp->sd_lockstruct);
+}
Quoted 3 lines

I can't follow... test_bit does not modify *sdp or sdp->sd_flags, and gfs2_unmount_lockproto does not either.

sd_lockstruct is part of the superblock and fields in the lockstruct are changed by (for example) fs/gfs2/locking/dlm/mount.c: gdlm_unmount() so I don't think its valid to mark the superblock const here (despite being a great fan of using const in general).

Steve.

#6 lore raw

Hi,

Quoted 9 lines
Quoted 9 lines
Quoted 2 lines

Unfortunately thats not possible as the struct gfs2_sbd is actually changed lower down the call chain, but only in the lock_dlm module.

fs/gfs2/lm.c new file +5 -0
+void gfs2_lm_unmount(struct gfs2_sbd *sdp)
+{
+	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
+		gfs2_unmount_lockproto(&sdp->sd_lockstruct);
+}
Quoted 7 lines
Quoted 2 lines

I can't follow... test_bit does not modify *sdp or sdp->sd_flags, and gfs2_unmount_lockproto does not either.

sd_lockstruct is part of the superblock and fields in the lockstruct are changed by (for example) fs/gfs2/locking/dlm/mount.c: gdlm_unmount() so I don't think its valid to mark the superblock const here (despite being a great fan of using const in general).

Ah I just looked, and saw that

  struct {
      struct ... sd_lockstruct;
  } sdp;

sd_lockstruct is not a pointer but a struct in line. Yes, you are right. It would have been valid only if sd_lockstruct was a pointer to non-const memory.

Jan Engelhardt