linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: David Howells <dhowells@redhat.com>
Cc: cluster-devel@redhat.com, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] gfs2: Convert gfs2 to fs_context
Date: Thu, 21 Mar 2019 12:57:24 +0000	[thread overview]
Message-ID: <ba49049c-cdf5-9662-b3ae-24517e72c6e7@redhat.com> (raw)
In-Reply-To: <040cfbf7-9f27-b90b-262d-15a4e07eab32@redhat.com>

On 19/03/2019 17:53, Andrew Price wrote:
> On 19/03/2019 17:05, David Howells wrote:

>> Can you use vfs_get_block_super()?
> 
> It might be possible if we can rearrange things so that this can be done 
> outside of the function:
> 
>          if (args->ar_meta)
>                  fc->root = dget(sdp->sd_master_dir);
>          else
>                  fc->root = dget(sdp->sd_root_dir);
> 
> but we can't do that in our fill_super() because it needs to be selected 
> whether we have an existing mount or not.

Would this fly?

diff --git a/fs/super.c b/fs/super.c
index 6d8dbf309241..0cdeaf28126f 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1232,11 +1232,12 @@ static int test_bdev_super_fc(struct super_block 
*s, struct fs_context *fc)
   * @fill_super: Helper to initialise a new superblock
   */
  int vfs_get_block_super(struct fs_context *fc,
-                       int (*fill_super)(struct super_block *,
-                                         struct fs_context *))
+      int (*fill_super)(struct super_block *, struct fs_context *),
+      struct dentry* (*select_root)(struct fs_context *, struct 
super_block *))
  {
         struct block_device *bdev;
         struct super_block *s;
+       struct dentry *root;
         int error = 0;

         fc->bdev_mode = FMODE_READ | FMODE_EXCL;
@@ -1302,7 +1303,11 @@ int vfs_get_block_super(struct fs_context *fc,
         }

         BUG_ON(fc->root);
-       fc->root = dget(s->s_root);
+       if (select_root)
+               root = select_root(fc, s);
+       else
+               root = s->s_root;
+       fc->root = dget(root);
         return 0;

  error_sb:
diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h
index 8233c873af73..c2e9dc5826ce 100644
--- a/include/linux/fs_context.h
+++ b/include/linux/fs_context.h
@@ -145,8 +145,8 @@ extern int vfs_get_super(struct fs_context *fc,
                                            struct fs_context *fc));

  extern int vfs_get_block_super(struct fs_context *fc,
-                              int (*fill_super)(struct super_block *sb,
-                                                struct fs_context *fc));
+      int (*fill_super)(struct super_block *, struct fs_context *),
+      struct dentry* (*select_root)(struct fs_context *, struct 
super_block *));

  extern const struct file_operations fscontext_fops;


  reply	other threads:[~2019-03-21 12:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 16:04 [PATCH v2 0/2] gfs2: Switch to the new mount API Andrew Price
2019-03-19 16:04 ` [PATCH v2 1/2] gfs2: Convert gfs2 to fs_context Andrew Price
2019-03-19 16:04 ` [PATCH v2 2/2] gfs2: Convert gfs2meta " Andrew Price
2019-03-19 17:05 ` [PATCH v2 1/2] gfs2: Convert gfs2 " David Howells
2019-03-19 17:53   ` Andrew Price
2019-03-21 12:57     ` Andrew Price [this message]
2019-03-21 17:08     ` David Howells
2019-03-21 17:26       ` [PATCH] vfs: Allow selection of fs root independent of sb Andrew Price
2019-03-21 18:36         ` Matthew Wilcox
2019-03-21 17:59       ` David Howells

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=ba49049c-cdf5-9662-b3ae-24517e72c6e7@redhat.com \
    --to=anprice@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).