Skip to contentSkip to conversation

GFS2: Wait for journal id on mount if not specified on mount command line

Cluster-devel Steven Whitehouse 3 participants 6 messages Jun 7, 2010 – Jun 9, 2010 GFS2 file system

lore
Share & tools
lore
#0 lore raw

This patch implements a wait for the journal id in the case that it has not been specified on the command line. This is to allow the future removal of the mount.gfs2 helper. The journal id would instead be directly communicated by gfs_controld to the file system. Here is a comparison of the two systems:

Current:
1. mount calls mount.gfs2
2. mount.gfs2 connects to gfs_controld to retrieve the journal id
3. mount.gfs2 adds the journal id to the mount command line and calls the mount system call
4. gfs_controld receives the status of the mount request via a uevent

Proposed:
1. mount calls the mount system call (no mount.gfs2 helper)
2. gfs_controld receives a uevent for a gfs2 fs which it doesn't know about already
3. gfs_controld assigns a journal id to it via sysfs
4. the mount system call then completes as normal (sending a uevent according to status)

The advantage of the proposed system is that it is completely backward compatible with the current system both at the kernel and at the userland levels. The "first" parameter can also be set the same way, with the restriction that it must be set before the journal id is assigned.

In addition, if mount becomes stuck waiting for a reply from gfs_controld which never arrives, then it is killable and will abort the mount gracefully.

fs/gfs2/incore.h +1 -0
index b5d7363..8fcbce4 100644
@@ -460,6 +460,7 @@ enum {
 	SDF_NOBARRIERS		= 3,
 	SDF_NORECOVERY		= 4,
 	SDF_DEMOTE		= 5,
+	SDF_NOJOURNALID		= 6,
 };
 
 #define GFS2_FSNAME_LEN		256
fs/gfs2/ops_fstype.c +25 -2
index 3593b3a..45a4a36 100644
@@ -76,7 +76,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
 
 	sb->s_fs_info = sdp;
 	sdp->sd_vfs = sb;
-
+	set_bit(SDF_NOJOURNALID, &sdp->sd_flags);
 	gfs2_tune_init(&sdp->sd_tune);
 
 	init_waitqueue_head(&sdp->sd_glock_wait);
@@ -1050,7 +1050,8 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)
 			ret = match_int(&tmp[0], &option);
 			if (ret || option < 0) 
 				goto hostdata_error;
-			ls->ls_jid = option;
+			if (test_and_clear_bit(SDF_NOJOURNALID, &sdp->sd_flags))
+				ls->ls_jid = option;
 			break;
 		case Opt_id:
 			/* Obsolete, but left for backward compat purposes */
@@ -1102,6 +1103,24 @@ void gfs2_lm_unmount(struct gfs2_sbd *sdp)
 		lm->lm_unmount(sdp);
 }
 
+static int gfs2_journalid_wait(void *word)
+{
+	if (signal_pending(current))
+		return -EINTR;
+	schedule();
+	return 0;
+}
+
+static int wait_on_journal(struct gfs2_sbd *sdp)
+{
+	if (sdp->sd_args.ar_spectator)
+		return 0;
+	if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
+		return 0;
+
+	return wait_on_bit(&sdp->sd_flags, SDF_NOJOURNALID, gfs2_journalid_wait, TASK_INTERRUPTIBLE);
+}
+
 void gfs2_online_uevent(struct gfs2_sbd *sdp)
 {
 	struct super_block *sb = sdp->sd_vfs;
@@ -1194,6 +1213,10 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
 	if (error)
 		goto fail_locking;
 
+	error = wait_on_journal(sdp);
+	if (error)
+		goto fail_sb;
+
 	error = init_inodes(sdp, DO);
 	if (error)
 		goto fail_sb;
fs/gfs2/sys.c +54 -3

81 lines not on this page · raw message

#1 lore raw
Quoted 14 lines · Steven Whitehouse

This patch implements a wait for the journal id in the case that it has not been specified on the command line. This is to allow the future removal of the mount.gfs2 helper. The journal id would instead be directly communicated by gfs_controld to the file system. Here is a comparison of the two systems:

Current:
1. mount calls mount.gfs2
2. mount.gfs2 connects to gfs_controld to retrieve the journal id
3. mount.gfs2 adds the journal id to the mount command line and calls the mount system call
4. gfs_controld receives the status of the mount request via a uevent

Quoted 7 lines

Proposed:
1. mount calls the mount system call (no mount.gfs2 helper)
2. gfs_controld receives a uevent for a gfs2 fs which it doesn't know about already
3. gfs_controld assigns a journal id to it via sysfs
4. the mount system call then completes as normal (sending a uevent according to status)

Proposed is the way it originally worked. I switched to using Current back in 2005... unfortunately I don't remember all the specific reasons, but I'm pretty sure it was the error/edge cases that were better handled without sitting in the kernel early in the process. (Especially when you combine simultaneous mounting / mount failures / node failures / recovery.)

A couple obvious questions from the start...
- What if gfs_controld isn't running?
- Won't processes start to access the fs and block during this intermediate time between mount(2) and getting a journal id? All of those processes now need errors returned if gfs_controld returns an error instead of a journal id.

Another way to compare them:

Current:
- get all the userspace/clustering-related/error-laden overhead sorted out
- then, at the very end, pull the kernel fs into the picture
- collect the result of mount(2) in userpsace, which is almost always "success"

Proposed:
- pull the kernel fs into the picture
- transition to userspace to sort out all the clustering-related / error-laden overhead
- get back to the kernel with the result
- collect the result of mount(2) in userspace

The further you get before you encounter errors, the harder they are to handle. You want most errors to happen earlier, with fewer entities involved, so backing out is easier to do.

IIRC, nfs recently moved to using a mount helper after *not* using one for many years. It would be interesting to ask them about their motivations.

Quoted 5 lines

The advantage of the proposed system is that it is completely backward compatible with the current system both at the kernel and at the userland levels. The "first" parameter can also be set the same way, with the restriction that it must be set before the journal id is assigned.

That's not an "advantage" of new versus old, which is the missing bit of information here. I'm not against changing it per se, but it seems we'd want some substantial advantage before going to all the effort of changing such a delicate area that has worked quite well for the past 5 years.

There's room for real, major improvements in this whole area, but you're barking up the wrong tree. gfs_controld has always been far too complex. But it's *not* a result of current mount helper scheme. It is a direct result of gfs_controld being required to do jobs that gfs (in kernel) should probably handle itself: allocating journal id's, coordinating who does journal recovery, coordinating first mounter recovery, sorting out valid combinations of mount options from different nodes, keeping track of recovered journals vs journals that haven't been recovered, coordinating when all journals have been successfully recovered so that normal fs access can be continued.

If you want to do something that's meaningful and beneficial in this area, you need to look at moving *those* things from gfs_controld into gfs. Ocfs2 is a good example here, it handles almost all of that stuff in the kernel, and leaves only what's really necessary for ocfs2_controld.

In fact, this could be a perfect area for gfs2/ocfs2 unification: adopt a single fs_controld, single mount/unmount scheme, single node failure/recovery notification scheme, single journal id/allocation scheme.

Dave

#2 lore raw

Hi,

Quoted 23 lines · David Teigland
Quoted 14 lines · Steven Whitehouse

This patch implements a wait for the journal id in the case that it has not been specified on the command line. This is to allow the future removal of the mount.gfs2 helper. The journal id would instead be directly communicated by gfs_controld to the file system. Here is a comparison of the two systems:

Current:
1. mount calls mount.gfs2
2. mount.gfs2 connects to gfs_controld to retrieve the journal id
3. mount.gfs2 adds the journal id to the mount command line and calls the mount system call
4. gfs_controld receives the status of the mount request via a uevent

Quoted 7 lines

Proposed:
1. mount calls the mount system call (no mount.gfs2 helper)
2. gfs_controld receives a uevent for a gfs2 fs which it doesn't know about already
3. gfs_controld assigns a journal id to it via sysfs
4. the mount system call then completes as normal (sending a uevent according to status)

Quoted 8 lines

Proposed is the way it originally worked. I switched to using Current back in 2005... unfortunately I don't remember all the specific reasons, but I'm pretty sure it was the error/edge cases that were better handled without sitting in the kernel early in the process. (Especially when you combine simultaneous mounting / mount failures / node failures / recovery.)

A couple obvious questions from the start...
- What if gfs_controld isn't running?

It will hang until mount is killed, where upon it will clean up and exit gracefully.

Quoted 4 lines

- Won't processes start to access the fs and block during this intermediate time between mount(2) and getting a journal id? All of those processes now need errors returned if gfs_controld returns an error instead of a journal id.

Nothing can access the fs until mount completes successfully.

Quoted 9 lines

Another way to compare them:

Current:
- get all the userspace/clustering-related/error-laden overhead sorted out
- then, at the very end, pull the kernel fs into the picture
- collect the result of mount(2) in userpsace, which is almost always "success"

But that isn't the way it works currently. The first mount result (and recovery results) are collected via uevents, even in the current scheme.

Quoted 11 lines

Proposed:
- pull the kernel fs into the picture
- transition to userspace to sort out all the clustering-related / error-laden overhead
- get back to the kernel with the result
- collect the result of mount(2) in userspace

The further you get before you encounter errors, the harder they are to handle. You want most errors to happen earlier, with fewer entities involved, so backing out is easier to do.

There isn't a great difference between the error handling in either case. There is one extra case for the kernel to handle, that of getting an invalid journal id, or not getting a journal id at all. The actual sequence of events is pretty similar, the main difference being that gfs_controld talks directly to the fs in all cases, rather than using mount.gfs2 as in intermediate point in the communications. Since gfs_controld already communicates directly with the fs anyway for a number of other reasons, it seems reasonable to cut out the middle man in this one remaining case where we have the mount helper in order to simplify the system.

Quoted 3 lines

IIRC, nfs recently moved to using a mount helper after *not* using one for many years. It would be interesting to ask them about their motivations.

We can ask by all means, but I'm not sure its relevant to this situation.

Quoted 28 lines
Quoted 6 lines

The advantage of the proposed system is that it is completely backward compatible with the current system both at the kernel and at the userland levels. The "first" parameter can also be set the same way, with the restriction that it must be set before the journal id is assigned.

That's not an "advantage" of new versus old, which is the missing bit of information here. I'm not against changing it per se, but it seems we'd want some substantial advantage before going to all the effort of changing such a delicate area that has worked quite well for the past 5 years.

There's room for real, major improvements in this whole area, but you're barking up the wrong tree. gfs_controld has always been far too complex. But it's *not* a result of current mount helper scheme. It is a direct result of gfs_controld being required to do jobs that gfs (in kernel) should probably handle itself: allocating journal id's, coordinating who does journal recovery, coordinating first mounter recovery, sorting out valid combinations of mount options from different nodes, keeping track of recovered journals vs journals that haven't been recovered, coordinating when all journals have been successfully recovered so that normal fs access can be continued.

If you want to do something that's meaningful and beneficial in this area, you need to look at moving *those* things from gfs_controld into gfs. Ocfs2 is a good example here, it handles almost all of that stuff in the kernel, and leaves only what's really necessary for ocfs2_controld.

Quoted 6 lines

In fact, this could be a perfect area for gfs2/ocfs2 unification: adopt a single fs_controld, single mount/unmount scheme, single node failure/recovery notification scheme, single journal id/allocation scheme.

Dave

The question is then, whether this could be made backward compatible with what we already have. I'm not sure how we could allocate journal ids in the kernel since we have no communication mechanism other than the locking.

Getting rid of mount.gfs2 results in there being one fewer userland program to maintain. It also removes the one major dependency between gfs2-utils and the cluster packages making builds much easier. In time we can simplify gfs_controld too since it would no longer need the code to talk to mount.gfs2.

Some of these changes are a long way off at the moment, since it will take some time before we can reasonably make all of the userland changes. In the mean time though, I think it is important to get the kernel changes in as soon as we can, in order to give us the opportunity of making the userland changes at a later date,

Steve.

#3 lore raw
Quoted 4 lines · Steven Whitehouse
Quoted 2 lines

A couple obvious questions from the start...
- What if gfs_controld isn't running?

It will hang until mount is killed, where upon it will clean up and exit gracefully.

Right, so instead of failing with an error, it hangs and requires a user to intervene and kill it. That's not good.

Quoted 5 lines
Quoted 4 lines

- Won't processes start to access the fs and block during this intermediate time between mount(2) and getting a journal id? All of those processes now need errors returned if gfs_controld returns an error instead of a journal id.

Nothing can access the fs until mount completes successfully.

Right, but does the access block indefinately waiting for all the userland nonsense to complete?

Quoted 20 lines
Quoted 6 lines

Current:
- get all the userspace/clustering-related/error-laden overhead sorted out
- then, at the very end, pull the kernel fs into the picture
- collect the result of mount(2) in userpsace, which is almost always "success"

But that isn't the way it works currently. The first mount result (and recovery results) are collected via uevents, even in the current scheme.

Quoted 11 lines

Proposed:
- pull the kernel fs into the picture
- transition to userspace to sort out all the clustering-related / error-laden overhead
- get back to the kernel with the result
- collect the result of mount(2) in userspace

The further you get before you encounter errors, the harder they are to handle. You want most errors to happen earlier, with fewer entities involved, so backing out is easier to do.

Quoted 10 lines

There isn't a great difference between the error handling in either case. There is one extra case for the kernel to handle, that of getting an invalid journal id, or not getting a journal id at all. The actual sequence of events is pretty similar, the main difference being that gfs_controld talks directly to the fs in all cases, rather than using mount.gfs2 as in intermediate point in the communications. Since gfs_controld already communicates directly with the fs anyway for a number of other reasons, it seems reasonable to cut out the middle man in this one remaining case where we have the mount helper in order to simplify the system.

My comments on really simplifying things are at the end; this just rearranges the complexity. If we're going to take the dive into reworking this code, at least make it worth the effort.

Quoted 4 lines

The question is then, whether this could be made backward compatible with what we already have. I'm not sure how we could allocate journal ids in the kernel since we have no communication mechanism other than the locking.

The dlm should work fine. You'd want to move all the journal related stuff into gfs2: allocating jid, knowing which jid's are used by which nodes, knowing which journals need recovery, etc. Ocfs2 does all this stuff itself; you may be able to copy a bunch of it (or share!)

Quoted 11 lines

Getting rid of mount.gfs2 results in there being one fewer userland program to maintain. It also removes the one major dependency between gfs2-utils and the cluster packages making builds much easier. In time we can simplify gfs_controld too since it would no longer need the code to talk to mount.gfs2.

Some of these changes are a long way off at the moment, since it will take some time before we can reasonably make all of the userland changes. In the mean time though, I think it is important to get the kernel changes in as soon as we can, in order to give us the opportunity of making the userland changes at a later date,

The changes you're suggesting may seem minor to you, but they involve changing how very core and delicate interactions work. It's senseless to change that kind of stuff without a very good reason. Serious simplification would qualify, but rearranging the deck chairs doesn't.

Dave

#4 lore raw

Hi,

Quoted 9 lines · David Teigland
Quoted 4 lines · Steven Whitehouse
Quoted 2 lines

A couple obvious questions from the start...
- What if gfs_controld isn't running?

It will hang until mount is killed, where upon it will clean up and exit gracefully.

Right, so instead of failing with an error, it hangs and requires a user to intervene and kill it. That's not good.

Well we could make it time out, but I fail to see why its not good. They are not going to be able to mount the fs anyway, given that this is only going to occur when gfs_controld is not configured.

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

- Won't processes start to access the fs and block during this intermediate time between mount(2) and getting a journal id? All of those processes now need errors returned if gfs_controld returns an error instead of a journal id.

Nothing can access the fs until mount completes successfully.

Right, but does the access block indefinately waiting for all the userland nonsense to complete?

Yes, although we could make it timeout, but I'm not convinced that we need to do that.

Quoted 40 lines
Quoted 20 lines
Quoted 6 lines

Current:
- get all the userspace/clustering-related/error-laden overhead sorted out
- then, at the very end, pull the kernel fs into the picture
- collect the result of mount(2) in userpsace, which is almost always "success"

But that isn't the way it works currently. The first mount result (and recovery results) are collected via uevents, even in the current scheme.

Quoted 11 lines

Proposed:
- pull the kernel fs into the picture
- transition to userspace to sort out all the clustering-related / error-laden overhead
- get back to the kernel with the result
- collect the result of mount(2) in userspace

The further you get before you encounter errors, the harder they are to handle. You want most errors to happen earlier, with fewer entities involved, so backing out is easier to do.

Quoted 10 lines

There isn't a great difference between the error handling in either case. There is one extra case for the kernel to handle, that of getting an invalid journal id, or not getting a journal id at all. The actual sequence of events is pretty similar, the main difference being that gfs_controld talks directly to the fs in all cases, rather than using mount.gfs2 as in intermediate point in the communications. Since gfs_controld already communicates directly with the fs anyway for a number of other reasons, it seems reasonable to cut out the middle man in this one remaining case where we have the mount helper in order to simplify the system.

My comments on really simplifying things are at the end; this just rearranges the complexity. If we're going to take the dive into reworking this code, at least make it worth the effort.

Quoted 4 lines

The question is then, whether this could be made backward compatible with what we already have. I'm not sure how we could allocate journal ids in the kernel since we have no communication mechanism other than the locking.

Quoted 5 lines

The dlm should work fine. You'd want to move all the journal related stuff into gfs2: allocating jid, knowing which jid's are used by which nodes, knowing which journals need recovery, etc. Ocfs2 does all this stuff itself; you may be able to copy a bunch of it (or share!)

OCFS2 appears to keep the journal state (wrt to allocation to nodes and also recovery state) on disk. Whilst that might well be sensible, it would be rather tricky to try and introduce that at this stage. It couldn't possibly be backward compatible after that change, since older nodes would not know how to read that information, and would thus still be reliant on the existing infrastructure.

I don't want to rule out making a change if there is a sensible way to implement it, but its not obvious to me how we'd do that at the moment.

Quoted 12 lines
Quoted 11 lines

Getting rid of mount.gfs2 results in there being one fewer userland program to maintain. It also removes the one major dependency between gfs2-utils and the cluster packages making builds much easier. In time we can simplify gfs_controld too since it would no longer need the code to talk to mount.gfs2.

Some of these changes are a long way off at the moment, since it will take some time before we can reasonably make all of the userland changes. In the mean time though, I think it is important to get the kernel changes in as soon as we can, in order to give us the opportunity of making the userland changes at a later date,

Quoted 7 lines

The changes you're suggesting may seem minor to you, but they involve changing how very core and delicate interactions work. It's senseless to change that kind of stuff without a very good reason. Serious simplification would qualify, but rearranging the deck chairs doesn't.

Dave

This is a serious simplification. We lose a dependency between packages and at the same time, we have one less program to maintain. Making this change doesn't preclude further changes if we can then work out how to implement them in a backward compatible way.

I didn't claim that the change was minor, but it is certainly a lot less invasive than your suggestion of replacing the whole system. Thats not to say I'm against doing that, but I'd prefer to do it carefully, one bit at a time,

Steve.

#5 lore raw
In reply to David Teigland
Quoted 2 lines · David Teigland

IIRC, nfs recently moved to using a mount helper after *not* using one for many years. It would be interesting to ask them about their motivations.

That's not correct at all. NFS has required special mount code since day 1 and continues to do so. The only change is that this code used to be built into the mount binary and now has moved to a helper in the nfs-tools package.