From: Liu Bo <bo.li.liu@oracle.com> To: Jan Kara <jack@suse.cz> Cc: linux-fsdevel@vger.kernel.org, Christoph Hellwig <hch@infradead.org>, linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nfs@vger.kernel.org, Petr Vandrovec <petr@vandrovec.name>, linux-nilfs@vger.kernel.org, cluster-devel@redhat.com, osd-dev@open-osd.org, codalist@TELEMANN.coda.cs.cmu.edu, linux-afs@lists.infradead.org, ecryptfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-btrfs@vger.kernel.org, v9fs-developer@lists.sourceforge.net, lustre-devel@lists.lustre.org Subject: Re: [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems Date: Thu, 2 Feb 2017 11:28:27 -0800 [thread overview] Message-ID: <20170202192827.GF6550@localhost.localdomain> (raw) In-Reply-To: <20170202173422.3240-5-jack@suse.cz> Hi, On Thu, Feb 02, 2017 at 06:34:02PM +0100, Jan Kara wrote: > Provide helper functions for setting up dynamically allocated > backing_dev_info structures for filesystems and cleaning them up on > superblock destruction. Just one concern, will this cause problems for multiple superblock cases like nfs with nosharecache? Thanks, -liubo > > CC: linux-mtd@lists.infradead.org > CC: linux-nfs@vger.kernel.org > CC: Petr Vandrovec <petr@vandrovec.name> > CC: linux-nilfs@vger.kernel.org > CC: cluster-devel@redhat.com > CC: osd-dev@open-osd.org > CC: codalist@coda.cs.cmu.edu > CC: linux-afs@lists.infradead.org > CC: ecryptfs@vger.kernel.org > CC: linux-cifs@vger.kernel.org > CC: ceph-devel@vger.kernel.org > CC: linux-btrfs@vger.kernel.org > CC: v9fs-developer@lists.sourceforge.net > CC: lustre-devel@lists.lustre.org > Signed-off-by: Jan Kara <jack@suse.cz> > --- > fs/super.c | 49 ++++++++++++++++++++++++++++++++++++++++ > include/linux/backing-dev-defs.h | 2 +- > include/linux/fs.h | 6 +++++ > 3 files changed, 56 insertions(+), 1 deletion(-) > > diff --git a/fs/super.c b/fs/super.c > index ea662b0e5e78..31dc4c6450ef 100644 > --- a/fs/super.c > +++ b/fs/super.c > @@ -446,6 +446,11 @@ void generic_shutdown_super(struct super_block *sb) > hlist_del_init(&sb->s_instances); > spin_unlock(&sb_lock); > up_write(&sb->s_umount); > + if (sb->s_iflags & SB_I_DYNBDI) { > + bdi_put(sb->s_bdi); > + sb->s_bdi = &noop_backing_dev_info; > + sb->s_iflags &= ~SB_I_DYNBDI; > + } > } > > EXPORT_SYMBOL(generic_shutdown_super); > @@ -1249,6 +1254,50 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data) > } > > /* > + * Setup private BDI for given superblock. I gets automatically cleaned up > + * in generic_shutdown_super(). > + */ > +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) > +{ > + struct backing_dev_info *bdi; > + int err; > + va_list args; > + > + bdi = bdi_alloc(GFP_KERNEL); > + if (!bdi) > + return -ENOMEM; > + > + bdi->name = sb->s_type->name; > + > + va_start(args, fmt); > + err = bdi_register_va(bdi, NULL, fmt, args); > + va_end(args); > + if (err) { > + bdi_put(bdi); > + return err; > + } > + WARN_ON(sb->s_bdi != &noop_backing_dev_info); > + sb->s_bdi = bdi; > + sb->s_iflags |= SB_I_DYNBDI; > + > + return 0; > +} > +EXPORT_SYMBOL(super_setup_bdi_name); > + > +/* > + * Setup private BDI for given superblock. I gets automatically cleaned up > + * in generic_shutdown_super(). > + */ > +int super_setup_bdi(struct super_block *sb) > +{ > + static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0); > + > + return super_setup_bdi_name(sb, "%.28s-%ld", sb->s_type->name, > + atomic_long_inc_return(&bdi_seq)); > +} > +EXPORT_SYMBOL(super_setup_bdi); > + > +/* > * This is an internal function, please use sb_end_{write,pagefault,intwrite} > * instead. > */ > diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h > index 2ecafc8a2d06..70080b4217f4 100644 > --- a/include/linux/backing-dev-defs.h > +++ b/include/linux/backing-dev-defs.h > @@ -143,7 +143,7 @@ struct backing_dev_info { > congested_fn *congested_fn; /* Function pointer if device is md/dm */ > void *congested_data; /* Pointer to aux data for congested func */ > > - char *name; > + const char *name; > > struct kref refcnt; /* Reference counter for the structure */ > unsigned int registered:1; /* Is bdi registered? */ > diff --git a/include/linux/fs.h b/include/linux/fs.h > index c930cbc19342..8ed8b6d1bc54 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1267,6 +1267,9 @@ struct mm_struct; > /* sb->s_iflags to limit user namespace mounts */ > #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ > > +/* Temporary flag until all filesystems are converted to dynamic bdis */ > +#define SB_I_DYNBDI 0x00000100 > + > /* Possible states of 'frozen' field */ > enum { > SB_UNFROZEN = 0, /* FS is unfrozen */ > @@ -2103,6 +2106,9 @@ extern int vfs_ustat(dev_t, struct kstatfs *); > extern int freeze_super(struct super_block *super); > extern int thaw_super(struct super_block *super); > extern bool our_mnt(struct vfsmount *mnt); > +extern __printf(2, 3) > +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...); > +extern int super_setup_bdi(struct super_block *sb); > > extern int current_umask(void); > > -- > 2.10.2 >
WARNING: multiple messages have this Message-ID (diff)
From: Liu Bo <bo.li.liu@oracle.com> To: cluster-devel.redhat.com Subject: [Cluster-devel] [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems Date: Thu, 2 Feb 2017 11:28:27 -0800 [thread overview] Message-ID: <20170202192827.GF6550@localhost.localdomain> (raw) In-Reply-To: <20170202173422.3240-5-jack@suse.cz> Hi, On Thu, Feb 02, 2017 at 06:34:02PM +0100, Jan Kara wrote: > Provide helper functions for setting up dynamically allocated > backing_dev_info structures for filesystems and cleaning them up on > superblock destruction. Just one concern, will this cause problems for multiple superblock cases like nfs with nosharecache? Thanks, -liubo > > CC: linux-mtd at lists.infradead.org > CC: linux-nfs at vger.kernel.org > CC: Petr Vandrovec <petr@vandrovec.name> > CC: linux-nilfs at vger.kernel.org > CC: cluster-devel at redhat.com > CC: osd-dev at open-osd.org > CC: codalist at coda.cs.cmu.edu > CC: linux-afs at lists.infradead.org > CC: ecryptfs at vger.kernel.org > CC: linux-cifs at vger.kernel.org > CC: ceph-devel at vger.kernel.org > CC: linux-btrfs at vger.kernel.org > CC: v9fs-developer at lists.sourceforge.net > CC: lustre-devel at lists.lustre.org > Signed-off-by: Jan Kara <jack@suse.cz> > --- > fs/super.c | 49 ++++++++++++++++++++++++++++++++++++++++ > include/linux/backing-dev-defs.h | 2 +- > include/linux/fs.h | 6 +++++ > 3 files changed, 56 insertions(+), 1 deletion(-) > > diff --git a/fs/super.c b/fs/super.c > index ea662b0e5e78..31dc4c6450ef 100644 > --- a/fs/super.c > +++ b/fs/super.c > @@ -446,6 +446,11 @@ void generic_shutdown_super(struct super_block *sb) > hlist_del_init(&sb->s_instances); > spin_unlock(&sb_lock); > up_write(&sb->s_umount); > + if (sb->s_iflags & SB_I_DYNBDI) { > + bdi_put(sb->s_bdi); > + sb->s_bdi = &noop_backing_dev_info; > + sb->s_iflags &= ~SB_I_DYNBDI; > + } > } > > EXPORT_SYMBOL(generic_shutdown_super); > @@ -1249,6 +1254,50 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data) > } > > /* > + * Setup private BDI for given superblock. I gets automatically cleaned up > + * in generic_shutdown_super(). > + */ > +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) > +{ > + struct backing_dev_info *bdi; > + int err; > + va_list args; > + > + bdi = bdi_alloc(GFP_KERNEL); > + if (!bdi) > + return -ENOMEM; > + > + bdi->name = sb->s_type->name; > + > + va_start(args, fmt); > + err = bdi_register_va(bdi, NULL, fmt, args); > + va_end(args); > + if (err) { > + bdi_put(bdi); > + return err; > + } > + WARN_ON(sb->s_bdi != &noop_backing_dev_info); > + sb->s_bdi = bdi; > + sb->s_iflags |= SB_I_DYNBDI; > + > + return 0; > +} > +EXPORT_SYMBOL(super_setup_bdi_name); > + > +/* > + * Setup private BDI for given superblock. I gets automatically cleaned up > + * in generic_shutdown_super(). > + */ > +int super_setup_bdi(struct super_block *sb) > +{ > + static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0); > + > + return super_setup_bdi_name(sb, "%.28s-%ld", sb->s_type->name, > + atomic_long_inc_return(&bdi_seq)); > +} > +EXPORT_SYMBOL(super_setup_bdi); > + > +/* > * This is an internal function, please use sb_end_{write,pagefault,intwrite} > * instead. > */ > diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h > index 2ecafc8a2d06..70080b4217f4 100644 > --- a/include/linux/backing-dev-defs.h > +++ b/include/linux/backing-dev-defs.h > @@ -143,7 +143,7 @@ struct backing_dev_info { > congested_fn *congested_fn; /* Function pointer if device is md/dm */ > void *congested_data; /* Pointer to aux data for congested func */ > > - char *name; > + const char *name; > > struct kref refcnt; /* Reference counter for the structure */ > unsigned int registered:1; /* Is bdi registered? */ > diff --git a/include/linux/fs.h b/include/linux/fs.h > index c930cbc19342..8ed8b6d1bc54 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1267,6 +1267,9 @@ struct mm_struct; > /* sb->s_iflags to limit user namespace mounts */ > #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ > > +/* Temporary flag until all filesystems are converted to dynamic bdis */ > +#define SB_I_DYNBDI 0x00000100 > + > /* Possible states of 'frozen' field */ > enum { > SB_UNFROZEN = 0, /* FS is unfrozen */ > @@ -2103,6 +2106,9 @@ extern int vfs_ustat(dev_t, struct kstatfs *); > extern int freeze_super(struct super_block *super); > extern int thaw_super(struct super_block *super); > extern bool our_mnt(struct vfsmount *mnt); > +extern __printf(2, 3) > +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...); > +extern int super_setup_bdi(struct super_block *sb); > > extern int current_umask(void); > > -- > 2.10.2 >
next prev parent reply other threads:[~2017-02-02 19:28 UTC|newest] Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-02-02 17:33 [PATCH 0/24 RFC] fs: Convert all embedded bdis into separate ones Jan Kara 2017-02-02 17:33 ` [Cluster-devel] " Jan Kara 2017-02-02 17:33 ` [lustre-devel] " Jan Kara 2017-02-02 17:33 ` Jan Kara 2017-02-02 17:33 ` Jan Kara 2017-02-02 17:33 ` Jan Kara 2017-02-02 17:33 ` [PATCH 01/24] block: Provide bdi_alloc() Jan Kara 2017-02-02 17:34 ` [PATCH 02/24] bdi: Provide bdi_register_va() Jan Kara 2017-02-02 17:34 ` [PATCH 03/24] block: Unregister bdi on last reference drop Jan Kara 2017-02-02 17:34 ` [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems Jan Kara 2017-02-02 17:34 ` [Cluster-devel] " Jan Kara 2017-02-02 17:34 ` [lustre-devel] " Jan Kara 2017-02-02 17:34 ` Jan Kara 2017-02-02 17:34 ` Jan Kara 2017-02-02 19:28 ` Liu Bo [this message] 2017-02-02 19:28 ` [Cluster-devel] " Liu Bo 2017-02-03 13:50 ` Jan Kara 2017-02-03 13:50 ` [Cluster-devel] " Jan Kara 2017-02-03 13:50 ` [lustre-devel] " Jan Kara 2017-02-03 18:31 ` Liu Bo 2017-02-03 18:31 ` [Cluster-devel] " Liu Bo 2017-02-03 18:31 ` Liu Bo 2017-02-08 0:38 ` [lustre-devel] " Dilger, Andreas 2017-02-08 0:38 ` [Cluster-devel] " Dilger, Andreas 2017-02-08 0:38 ` Dilger, Andreas 2017-02-08 0:38 ` Dilger, Andreas 2017-02-08 0:38 ` Dilger, Andreas 2017-02-08 0:38 ` [lustre-devel] " Dilger, Andreas 2017-02-09 12:12 ` Jan Kara 2017-02-09 12:12 ` [Cluster-devel] " Jan Kara 2017-02-09 12:12 ` Jan Kara 2017-02-09 12:12 ` Jan Kara 2017-02-09 12:12 ` Jan Kara 2017-02-09 12:12 ` Jan Kara 2017-02-09 12:12 ` [lustre-devel] " Jan Kara 2017-02-02 17:34 ` [PATCH 05/24] fs: Get proper reference for s_bdi Jan Kara 2017-02-09 14:36 ` Boaz Harrosh 2017-02-09 15:52 ` Jan Kara 2017-02-02 17:34 ` [PATCH 06/24] lustre: Convert to separately allocated bdi Jan Kara 2017-02-02 17:34 ` [lustre-devel] " Jan Kara 2017-02-08 0:38 ` Dilger, Andreas 2017-02-08 0:38 ` Dilger, Andreas 2017-02-02 17:34 ` [PATCH 07/24] 9p: " Jan Kara 2017-02-02 17:34 ` [PATCH 08/24] btrfs: " Jan Kara 2017-02-03 18:33 ` Liu Bo 2017-02-08 15:22 ` David Sterba 2017-02-02 17:34 ` [PATCH 09/24] ceph: " Jan Kara 2017-02-02 17:34 ` Jan Kara 2017-02-02 17:34 ` [PATCH 10/24] cifs: " Jan Kara 2017-02-02 17:34 ` [PATCH 11/24] ecryptfs: " Jan Kara 2017-02-02 17:34 ` Jan Kara 2017-02-03 23:54 ` Tyler Hicks 2017-02-02 17:34 ` [PATCH 12/24] afs: " Jan Kara 2017-02-02 17:34 ` [PATCH 13/24] orangefs: Remove orangefs_backing_dev_info Jan Kara 2017-02-02 17:34 ` [PATCH 14/24] mtd: Convert to dynamically allocated bdi infrastructure Jan Kara 2017-02-02 17:34 ` [PATCH 15/24] coda: Convert to separately allocated bdi Jan Kara 2017-02-02 17:34 ` [PATCH 16/24] exofs: " Jan Kara 2017-02-09 14:23 ` Boaz Harrosh 2017-02-02 17:34 ` [PATCH 17/24] fuse: " Jan Kara 2017-02-07 9:16 ` Miklos Szeredi 2017-02-07 11:35 ` Jan Kara 2017-02-02 17:34 ` [PATCH 18/24] gfs2: Convert to properly refcounting bdi Jan Kara 2017-02-02 17:34 ` [Cluster-devel] " Jan Kara 2017-02-02 17:34 ` [PATCH 19/24] nilfs2: " Jan Kara 2017-02-02 17:34 ` Jan Kara 2017-02-02 17:34 ` [PATCH 20/24] ncpfs: Convert to separately allocated bdi Jan Kara 2017-02-02 17:34 ` [PATCH 21/24] nfs: " Jan Kara 2017-02-02 17:34 ` [PATCH 22/24] ubifs: " Jan Kara 2017-02-02 20:34 ` Richard Weinberger 2017-02-03 13:45 ` Jan Kara 2017-02-08 11:24 ` Richard Weinberger 2017-02-09 12:17 ` Jan Kara 2017-02-09 14:56 ` Richard Weinberger 2017-02-02 17:34 ` [PATCH 23/24] fs: Remove SB_I_DYNBDI flag Jan Kara 2017-02-02 17:34 ` [PATCH 24/24] block: Remove unused functions Jan Kara
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=20170202192827.GF6550@localhost.localdomain \ --to=bo.li.liu@oracle.com \ --cc=ceph-devel@vger.kernel.org \ --cc=cluster-devel@redhat.com \ --cc=codalist@TELEMANN.coda.cs.cmu.edu \ --cc=ecryptfs@vger.kernel.org \ --cc=hch@infradead.org \ --cc=jack@suse.cz \ --cc=linux-afs@lists.infradead.org \ --cc=linux-block@vger.kernel.org \ --cc=linux-btrfs@vger.kernel.org \ --cc=linux-cifs@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-mtd@lists.infradead.org \ --cc=linux-nfs@vger.kernel.org \ --cc=linux-nilfs@vger.kernel.org \ --cc=lustre-devel@lists.lustre.org \ --cc=osd-dev@open-osd.org \ --cc=petr@vandrovec.name \ --cc=v9fs-developer@lists.sourceforge.net \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.