Cluster-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] GFS2: Allow all meta/normal mount combinations
@ 2009-06-05 13:52 Steven Whitehouse
  2009-06-05 14:09 ` [Cluster-devel] " Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Whitehouse @ 2009-06-05 13:52 UTC (permalink / raw)
  To: cluster-devel.redhat.com


This patch enables the mounting of a GFS2 filesystem both by
specifying a block device, and by specifying an inode on an
existing GFS2 filesystem.

The "meta" option is now supported as a per vfsmnt option, rather
than a per sb option. This means that it is now possible to mount
the GFS2 filesystem normally or with the meta flag and in any order
(meta mounts relative to normal mounts).

The userland tools don't currently allow this feature to work in
clustered mode (they can be updated to do so) but in the mean
time the feature is available for single node filesystems.

I've tested this with all the combinations I can think of, and they
appear to work correctly.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>

diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 9da161c..ed1d997 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1267,12 +1267,6 @@ fail:
 	return error;
 }
 
-static int gfs2_get_sb(struct file_system_type *fs_type, int flags,
-		       const char *dev_name, void *data, struct vfsmount *mnt)
-{
-	return get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt);
-}
-
 static int test_meta_super(struct super_block *s, void *ptr)
 {
 	struct block_device *bdev = ptr;
@@ -1294,7 +1288,7 @@ static struct super_block *get_gfs2_sb(const char *dev_name)
 	if (error) {
 		printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n",
 		       dev_name, error);
-		return ERR_PTR(-ENOENT);
+		return ERR_PTR(error);
 	}
 	s = sget(&gfs2_fs_type, test_meta_super, set_meta_super,
 		 path.dentry->d_inode->i_sb->s_bdev);
@@ -1302,6 +1296,53 @@ static struct super_block *get_gfs2_sb(const char *dev_name)
 	return s;
 }
 
+/**
+ * gfs2_is_meta_fs
+ * @options: The options to parse
+ *
+ * The meta option is per mnt not per sb
+ */
+
+static int gfs2_is_meta_fs(char *options)
+{
+	char *o;
+
+	while(1) {
+		o = strsep(&options, ",");
+		if (o == NULL)
+			break;
+		if (strcmp(o, "meta") == 0)
+			return 1;
+	}
+
+	return 0;
+}
+
+static int gfs2_get_sb(struct file_system_type *fs_type, int flags,
+		       const char *dev_name, void *data, struct vfsmount *mnt)
+{
+	struct super_block *s;
+	struct gfs2_sbd *sdp;
+	int ret;
+
+	/* First we assume its a block device */
+	ret = get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt);
+	if (ret != -ENOTBLK)
+		return ret;
+
+	/* If that fails, we assume its a GFS2 inode on an existing sb */
+	s = get_gfs2_sb(dev_name);
+	if (IS_ERR(s)) {
+		printk(KERN_WARNING "GFS2: gfs2 mount does not exist\n");
+		return PTR_ERR(s);
+	}
+	sdp = s->s_fs_info;
+	mnt->mnt_sb = s;
+	mnt->mnt_root = gfs2_is_meta_fs(data) ? dget(sdp->sd_master_dir) :
+						dget(sdp->sd_root_dir);
+	return 0;
+}
+
 static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags,
 			    const char *dev_name, void *data, struct vfsmount *mnt)
 {




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] Re: GFS2: Allow all meta/normal mount combinations
  2009-06-05 13:52 [Cluster-devel] GFS2: Allow all meta/normal mount combinations Steven Whitehouse
@ 2009-06-05 14:09 ` Christoph Hellwig
  2009-06-05 14:17   ` Steven Whitehouse
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2009-06-05 14:09 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Fri, Jun 05, 2009 at 02:52:16PM +0100, Steven Whitehouse wrote:
> +static int gfs2_get_sb(struct file_system_type *fs_type, int flags,
> +		       const char *dev_name, void *data, struct vfsmount *mnt)
> +{
> +	struct super_block *s;
> +	struct gfs2_sbd *sdp;
> +	int ret;
> +
> +	/* First we assume its a block device */
> +	ret = get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt);
> +	if (ret != -ENOTBLK)
> +		return ret;
> +
> +	/* If that fails, we assume its a GFS2 inode on an existing sb */
> +	s = get_gfs2_sb(dev_name);
> +	if (IS_ERR(s)) {
> +		printk(KERN_WARNING "GFS2: gfs2 mount does not exist\n");
> +		return PTR_ERR(s);
> +	}

This is pretty ugly.  Even if this is how the old gfs2meta filesystem
worked I would prefer to only allow it if mounted as type gfs2meta, not
for normal gfs2 mount and gradually phase it out.

> +	sdp = s->s_fs_info;
> +	mnt->mnt_sb = s;
> +	mnt->mnt_root = gfs2_is_meta_fs(data) ? dget(sdp->sd_master_dir) :
> +						dget(sdp->sd_root_dir);

	if (gfs2_is_meta_fs(data))
		mnt->mnt_root = dget(sdp->sd_master_dir);
	else
		mnt->mnt_root = dget(sdp->sd_root_dir);

would be a lot more readable..



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Cluster-devel] Re: GFS2: Allow all meta/normal mount combinations
  2009-06-05 14:09 ` [Cluster-devel] " Christoph Hellwig
@ 2009-06-05 14:17   ` Steven Whitehouse
  2009-06-08 16:12     ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Whitehouse @ 2009-06-05 14:17 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On Fri, 2009-06-05 at 10:09 -0400, Christoph Hellwig wrote:
> On Fri, Jun 05, 2009 at 02:52:16PM +0100, Steven Whitehouse wrote:
> > +static int gfs2_get_sb(struct file_system_type *fs_type, int flags,
> > +		       const char *dev_name, void *data, struct vfsmount *mnt)
> > +{
> > +	struct super_block *s;
> > +	struct gfs2_sbd *sdp;
> > +	int ret;
> > +
> > +	/* First we assume its a block device */
> > +	ret = get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt);
> > +	if (ret != -ENOTBLK)
> > +		return ret;
> > +
> > +	/* If that fails, we assume its a GFS2 inode on an existing sb */
> > +	s = get_gfs2_sb(dev_name);
> > +	if (IS_ERR(s)) {
> > +		printk(KERN_WARNING "GFS2: gfs2 mount does not exist\n");
> > +		return PTR_ERR(s);
> > +	}
> 
> This is pretty ugly.  Even if this is how the old gfs2meta filesystem
> worked I would prefer to only allow it if mounted as type gfs2meta, not
> for normal gfs2 mount and gradually phase it out.
> 
Which bit is ugly? We need to be able to do this to be sure that we can
get a metafs which exactly matches the "normal" fs without races I
think. Thats a requirement of the userland tools, unfortunately.

> > +	sdp = s->s_fs_info;
> > +	mnt->mnt_sb = s;
> > +	mnt->mnt_root = gfs2_is_meta_fs(data) ? dget(sdp->sd_master_dir) :
> > +						dget(sdp->sd_root_dir);
> 
> 	if (gfs2_is_meta_fs(data))
> 		mnt->mnt_root = dget(sdp->sd_master_dir);
> 	else
> 		mnt->mnt_root = dget(sdp->sd_root_dir);
> 
> would be a lot more readable..
Yes, thats true. I'll fix it,

Steve.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Cluster-devel] Re: GFS2: Allow all meta/normal mount combinations
  2009-06-05 14:17   ` Steven Whitehouse
@ 2009-06-08 16:12     ` Christoph Hellwig
  2009-06-08 16:17       ` Steven Whitehouse
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2009-06-08 16:12 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Fri, Jun 05, 2009 at 03:17:43PM +0100, Steven Whitehouse wrote:
> > This is pretty ugly.  Even if this is how the old gfs2meta filesystem
> > worked I would prefer to only allow it if mounted as type gfs2meta, not
> > for normal gfs2 mount and gradually phase it out.
> > 
> Which bit is ugly? We need to be able to do this to be sure that we can
> get a metafs which exactly matches the "normal" fs without races I
> think. Thats a requirement of the userland tools, unfortunately.

Well, the block device from /proc/self/mounts really is a unique
key you can get.

If you really insist on using a path to a file make sure that normal
mounts only take the block device, and meta mounts only take the file.

But even with that it's not a very clear interface.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Cluster-devel] Re: GFS2: Allow all meta/normal mount combinations
  2009-06-08 16:12     ` Christoph Hellwig
@ 2009-06-08 16:17       ` Steven Whitehouse
  0 siblings, 0 replies; 5+ messages in thread
From: Steven Whitehouse @ 2009-06-08 16:17 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On Mon, 2009-06-08 at 12:12 -0400, Christoph Hellwig wrote:
> On Fri, Jun 05, 2009 at 03:17:43PM +0100, Steven Whitehouse wrote:
> > > This is pretty ugly.  Even if this is how the old gfs2meta filesystem
> > > worked I would prefer to only allow it if mounted as type gfs2meta, not
> > > for normal gfs2 mount and gradually phase it out.
> > > 
> > Which bit is ugly? We need to be able to do this to be sure that we can
> > get a metafs which exactly matches the "normal" fs without races I
> > think. Thats a requirement of the userland tools, unfortunately.
> 
> Well, the block device from /proc/self/mounts really is a unique
> key you can get.
> 
> If you really insist on using a path to a file make sure that normal
> mounts only take the block device, and meta mounts only take the file.
> 
> But even with that it's not a very clear interface.
> 

Yes, ok. I think I'll drop this patch for now then. Using the block
device does seem to work ok, and we'd need to update the tools to for
the "file" based method.

We can update the tools to pass a device I think by parsing /proc/mounts
for the path of the "real" filesystem and then using the device entry to
pass to mount. That should solve the problem without needing to add this
patch,

Steve.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-08 16:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-05 13:52 [Cluster-devel] GFS2: Allow all meta/normal mount combinations Steven Whitehouse
2009-06-05 14:09 ` [Cluster-devel] " Christoph Hellwig
2009-06-05 14:17   ` Steven Whitehouse
2009-06-08 16:12     ` Christoph Hellwig
2009-06-08 16:17       ` Steven Whitehouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox