* [PATCH 0/24 RFC] fs: Convert all embedded bdis into separate ones @ 2017-02-02 17:33 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 ` [PATCH 08/24] btrfs: Convert to separately allocated bdi Jan Kara 0 siblings, 2 replies; 10+ messages in thread From: Jan Kara @ 2017-02-02 17:33 UTC (permalink / raw) To: linux-fsdevel Cc: Christoph Hellwig, linux-block, Jan Kara, linux-mtd, linux-nfs, Petr Vandrovec, linux-nilfs, cluster-devel, osd-dev, codalist, linux-afs, ecryptfs, linux-cifs, ceph-devel, linux-btrfs, v9fs-developer, lustre-devel Hello, this patch series converts all embedded occurences of struct backing_dev_info to use standalone dynamically allocated structures. This makes bdi handling unified across all bdi users and generally removes some boilerplate code from filesystems setting up their own bdi. It also allows us to remove some code from generic bdi implementation. The patches were only compile-tested for most filesystems (I've tested mounting only for NFS & btrfs) so fs maintainers please have a look whether the changes look sound to you. This series is based on top of bdi fixes that were merged into linux-block git tree. Honza ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems 2017-02-02 17:33 [PATCH 0/24 RFC] fs: Convert all embedded bdis into separate ones Jan Kara @ 2017-02-02 17:34 ` Jan Kara 2017-02-02 19:28 ` Liu Bo 2017-02-08 0:38 ` [lustre-devel] " Dilger, Andreas 2017-02-02 17:34 ` [PATCH 08/24] btrfs: Convert to separately allocated bdi Jan Kara 1 sibling, 2 replies; 10+ messages in thread From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw) To: linux-fsdevel Cc: Christoph Hellwig, linux-block, Jan Kara, linux-mtd, linux-nfs, Petr Vandrovec, linux-nilfs, cluster-devel, osd-dev, codalist, linux-afs, ecryptfs, linux-cifs, ceph-devel, linux-btrfs, v9fs-developer, lustre-devel Provide helper functions for setting up dynamically allocated backing_dev_info structures for filesystems and cleaning them up on superblock destruction. 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 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems 2017-02-02 17:34 ` [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems Jan Kara @ 2017-02-02 19:28 ` Liu Bo 2017-02-03 13:50 ` Jan Kara 2017-02-08 0:38 ` [lustre-devel] " Dilger, Andreas 1 sibling, 1 reply; 10+ messages in thread From: Liu Bo @ 2017-02-02 19:28 UTC (permalink / raw) To: Jan Kara Cc: linux-fsdevel, Christoph Hellwig, linux-block, linux-mtd, linux-nfs, Petr Vandrovec, linux-nilfs, cluster-devel, osd-dev, codalist, linux-afs, ecryptfs, linux-cifs, ceph-devel, linux-btrfs, v9fs-developer, lustre-devel 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 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems 2017-02-02 19:28 ` Liu Bo @ 2017-02-03 13:50 ` Jan Kara 2017-02-03 18:31 ` Liu Bo 0 siblings, 1 reply; 10+ messages in thread From: Jan Kara @ 2017-02-03 13:50 UTC (permalink / raw) To: Liu Bo Cc: Jan Kara, linux-fsdevel, Christoph Hellwig, linux-block, linux-mtd, linux-nfs, Petr Vandrovec, linux-nilfs, cluster-devel, osd-dev, codalist, linux-afs, ecryptfs, linux-cifs, ceph-devel, linux-btrfs, v9fs-developer, lustre-devel On Thu 02-02-17 11:28:27, Liu Bo wrote: > 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? Can you ellaborate a bit? I've looked for a while what nfs with nosharecache does but I didn't see how it would influence anything with bdis... Honza -- Jan Kara <jack@suse.com> SUSE Labs, CR ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems 2017-02-03 13:50 ` Jan Kara @ 2017-02-03 18:31 ` Liu Bo 0 siblings, 0 replies; 10+ messages in thread From: Liu Bo @ 2017-02-03 18:31 UTC (permalink / raw) To: Jan Kara Cc: linux-fsdevel, Christoph Hellwig, linux-block, linux-mtd, linux-nfs, Petr Vandrovec, linux-nilfs, cluster-devel, osd-dev, codalist, linux-afs, ecryptfs, linux-cifs, ceph-devel, linux-btrfs, v9fs-developer, lustre-devel On Fri, Feb 03, 2017 at 02:50:42PM +0100, Jan Kara wrote: > On Thu 02-02-17 11:28:27, Liu Bo wrote: > > 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? > > Can you ellaborate a bit? I've looked for a while what nfs with > nosharecache does but I didn't see how it would influence anything with > bdis... Oh, I missed that bdi_seq was static, then it should be fine. (I was worried about that nfs with nosharecache would have multiple superblocks and if each superblock has a bdi using the same bdi name, nfs-xx.) Thanks for the reply. Thanks, -liubo ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [lustre-devel] [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems 2017-02-02 17:34 ` [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems Jan Kara 2017-02-02 19:28 ` Liu Bo @ 2017-02-08 0:38 ` Dilger, Andreas 2017-02-09 12:12 ` Jan Kara 1 sibling, 1 reply; 10+ messages in thread From: Dilger, Andreas @ 2017-02-08 0:38 UTC (permalink / raw) To: Jan Kara Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-cifs@vger.kernel.org, ecryptfs@vger.kernel.org, codalist@coda.cs.cmu.edu, Christoph Hellwig, cluster-devel@redhat.com, linux-mtd@lists.infradead.org, osd-dev@open-osd.org, v9fs-developer@lists.sourceforge.net, ceph-devel@vger.kernel.org, Petr Vandrovec, linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, lustre-devel@lists.lustre.org On Feb 2, 2017, at 10:34, Jan Kara <jack@suse.cz> wrote: > > Provide helper functions for setting up dynamically allocated > backing_dev_info structures for filesystems and cleaning them up on > superblock destruction. > > 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 (typo) s/I/It/ Looks fine otherwise. > + * 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 > > _______________________________________________ > lustre-devel mailing list > lustre-devel@lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [lustre-devel] [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems 2017-02-08 0:38 ` [lustre-devel] " Dilger, Andreas @ 2017-02-09 12:12 ` Jan Kara 0 siblings, 0 replies; 10+ messages in thread From: Jan Kara @ 2017-02-09 12:12 UTC (permalink / raw) To: Dilger, Andreas Cc: Jan Kara, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-cifs@vger.kernel.org, ecryptfs@vger.kernel.org, codalist@coda.cs.cmu.edu, Christoph Hellwig, cluster-devel@redhat.com, linux-mtd@lists.infradead.org, osd-dev@open-osd.org, v9fs-developer@lists.sourceforge.net, ceph-devel@vger.kernel.org, Petr Vandrovec, linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, lustre-devel@lists.lustre.org > > @@ -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 > > (typo) s/I/It/ > > Looks fine otherwise. Thanks, fixed. Honza -- Jan Kara <jack@suse.com> SUSE Labs, CR ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 08/24] btrfs: Convert to separately allocated bdi 2017-02-02 17:33 [PATCH 0/24 RFC] fs: Convert all embedded bdis into separate ones 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 ` Jan Kara 2017-02-03 18:33 ` Liu Bo 2017-02-08 15:22 ` David Sterba 1 sibling, 2 replies; 10+ messages in thread From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw) To: linux-fsdevel Cc: Christoph Hellwig, linux-block, Jan Kara, Chris Mason, Josef Bacik, David Sterba, linux-btrfs Allocate struct backing_dev_info separately instead of embedding it inside superblock. This unifies handling of bdi among users. CC: Chris Mason <clm@fb.com> CC: Josef Bacik <jbacik@fb.com> CC: David Sterba <dsterba@suse.com> CC: linux-btrfs@vger.kernel.org Signed-off-by: Jan Kara <jack@suse.cz> --- fs/btrfs/ctree.h | 1 - fs/btrfs/disk-io.c | 36 +++++++----------------------------- fs/btrfs/super.c | 7 +++++++ 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 6a823719b6c5..1dc06f66dfcf 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -801,7 +801,6 @@ struct btrfs_fs_info { struct btrfs_super_block *super_for_commit; struct super_block *sb; struct inode *btree_inode; - struct backing_dev_info bdi; struct mutex tree_log_mutex; struct mutex transaction_kthread_mutex; struct mutex cleaner_mutex; diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 37a31b12bb0c..b25723e729c0 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1810,21 +1810,6 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits) return ret; } -static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi) -{ - int err; - - err = bdi_setup_and_register(bdi, "btrfs"); - if (err) - return err; - - bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE; - bdi->congested_fn = btrfs_congested_fn; - bdi->congested_data = info; - bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK; - return 0; -} - /* * called by the kthread helper functions to finally call the bio end_io * functions. This is where read checksum verification actually happens @@ -2598,16 +2583,10 @@ int open_ctree(struct super_block *sb, goto fail; } - ret = setup_bdi(fs_info, &fs_info->bdi); - if (ret) { - err = ret; - goto fail_srcu; - } - ret = percpu_counter_init(&fs_info->dirty_metadata_bytes, 0, GFP_KERNEL); if (ret) { err = ret; - goto fail_bdi; + goto fail_srcu; } fs_info->dirty_metadata_batch = PAGE_SIZE * (1 + ilog2(nr_cpu_ids)); @@ -2715,7 +2694,6 @@ int open_ctree(struct super_block *sb, sb->s_blocksize = 4096; sb->s_blocksize_bits = blksize_bits(4096); - sb->s_bdi = &fs_info->bdi; btrfs_init_btree_inode(fs_info); @@ -2912,9 +2890,12 @@ int open_ctree(struct super_block *sb, goto fail_sb_buffer; } - fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); - fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, - SZ_4M / PAGE_SIZE); + sb->s_bdi->congested_fn = btrfs_congested_fn; + sb->s_bdi->congested_data = fs_info; + sb->s_bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK; + sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE; + sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super); + sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE); sb->s_blocksize = sectorsize; sb->s_blocksize_bits = blksize_bits(sectorsize); @@ -3282,8 +3263,6 @@ int open_ctree(struct super_block *sb, percpu_counter_destroy(&fs_info->delalloc_bytes); fail_dirty_metadata_bytes: percpu_counter_destroy(&fs_info->dirty_metadata_bytes); -fail_bdi: - bdi_destroy(&fs_info->bdi); fail_srcu: cleanup_srcu_struct(&fs_info->subvol_srcu); fail: @@ -4010,7 +3989,6 @@ void close_ctree(struct btrfs_fs_info *fs_info) percpu_counter_destroy(&fs_info->dirty_metadata_bytes); percpu_counter_destroy(&fs_info->delalloc_bytes); percpu_counter_destroy(&fs_info->bio_counter); - bdi_destroy(&fs_info->bdi); cleanup_srcu_struct(&fs_info->subvol_srcu); btrfs_free_stripe_hash_table(fs_info); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index b5ae7d3d1896..08ef08b63132 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1133,6 +1133,13 @@ static int btrfs_fill_super(struct super_block *sb, #endif sb->s_flags |= MS_I_VERSION; sb->s_iflags |= SB_I_CGROUPWB; + + err = super_setup_bdi(sb); + if (err) { + btrfs_err(fs_info, "super_setup_bdi failed"); + return err; + } + err = open_ctree(sb, fs_devices, (char *)data); if (err) { btrfs_err(fs_info, "open_ctree failed"); -- 2.10.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 08/24] btrfs: Convert to separately allocated bdi 2017-02-02 17:34 ` [PATCH 08/24] btrfs: Convert to separately allocated bdi Jan Kara @ 2017-02-03 18:33 ` Liu Bo 2017-02-08 15:22 ` David Sterba 1 sibling, 0 replies; 10+ messages in thread From: Liu Bo @ 2017-02-03 18:33 UTC (permalink / raw) To: Jan Kara Cc: linux-fsdevel, Christoph Hellwig, linux-block, Chris Mason, Josef Bacik, David Sterba, linux-btrfs On Thu, Feb 02, 2017 at 06:34:06PM +0100, Jan Kara wrote: > Allocate struct backing_dev_info separately instead of embedding it > inside superblock. This unifies handling of bdi among users. Looks good. Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Thanks, -liubo > > CC: Chris Mason <clm@fb.com> > CC: Josef Bacik <jbacik@fb.com> > CC: David Sterba <dsterba@suse.com> > CC: linux-btrfs@vger.kernel.org > Signed-off-by: Jan Kara <jack@suse.cz> > --- > fs/btrfs/ctree.h | 1 - > fs/btrfs/disk-io.c | 36 +++++++----------------------------- > fs/btrfs/super.c | 7 +++++++ > 3 files changed, 14 insertions(+), 30 deletions(-) > > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h > index 6a823719b6c5..1dc06f66dfcf 100644 > --- a/fs/btrfs/ctree.h > +++ b/fs/btrfs/ctree.h > @@ -801,7 +801,6 @@ struct btrfs_fs_info { > struct btrfs_super_block *super_for_commit; > struct super_block *sb; > struct inode *btree_inode; > - struct backing_dev_info bdi; > struct mutex tree_log_mutex; > struct mutex transaction_kthread_mutex; > struct mutex cleaner_mutex; > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index 37a31b12bb0c..b25723e729c0 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -1810,21 +1810,6 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits) > return ret; > } > > -static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi) > -{ > - int err; > - > - err = bdi_setup_and_register(bdi, "btrfs"); > - if (err) > - return err; > - > - bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE; > - bdi->congested_fn = btrfs_congested_fn; > - bdi->congested_data = info; > - bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK; > - return 0; > -} > - > /* > * called by the kthread helper functions to finally call the bio end_io > * functions. This is where read checksum verification actually happens > @@ -2598,16 +2583,10 @@ int open_ctree(struct super_block *sb, > goto fail; > } > > - ret = setup_bdi(fs_info, &fs_info->bdi); > - if (ret) { > - err = ret; > - goto fail_srcu; > - } > - > ret = percpu_counter_init(&fs_info->dirty_metadata_bytes, 0, GFP_KERNEL); > if (ret) { > err = ret; > - goto fail_bdi; > + goto fail_srcu; > } > fs_info->dirty_metadata_batch = PAGE_SIZE * > (1 + ilog2(nr_cpu_ids)); > @@ -2715,7 +2694,6 @@ int open_ctree(struct super_block *sb, > > sb->s_blocksize = 4096; > sb->s_blocksize_bits = blksize_bits(4096); > - sb->s_bdi = &fs_info->bdi; > > btrfs_init_btree_inode(fs_info); > > @@ -2912,9 +2890,12 @@ int open_ctree(struct super_block *sb, > goto fail_sb_buffer; > } > > - fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); > - fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, > - SZ_4M / PAGE_SIZE); > + sb->s_bdi->congested_fn = btrfs_congested_fn; > + sb->s_bdi->congested_data = fs_info; > + sb->s_bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK; > + sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE; > + sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super); > + sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE); > > sb->s_blocksize = sectorsize; > sb->s_blocksize_bits = blksize_bits(sectorsize); > @@ -3282,8 +3263,6 @@ int open_ctree(struct super_block *sb, > percpu_counter_destroy(&fs_info->delalloc_bytes); > fail_dirty_metadata_bytes: > percpu_counter_destroy(&fs_info->dirty_metadata_bytes); > -fail_bdi: > - bdi_destroy(&fs_info->bdi); > fail_srcu: > cleanup_srcu_struct(&fs_info->subvol_srcu); > fail: > @@ -4010,7 +3989,6 @@ void close_ctree(struct btrfs_fs_info *fs_info) > percpu_counter_destroy(&fs_info->dirty_metadata_bytes); > percpu_counter_destroy(&fs_info->delalloc_bytes); > percpu_counter_destroy(&fs_info->bio_counter); > - bdi_destroy(&fs_info->bdi); > cleanup_srcu_struct(&fs_info->subvol_srcu); > > btrfs_free_stripe_hash_table(fs_info); > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c > index b5ae7d3d1896..08ef08b63132 100644 > --- a/fs/btrfs/super.c > +++ b/fs/btrfs/super.c > @@ -1133,6 +1133,13 @@ static int btrfs_fill_super(struct super_block *sb, > #endif > sb->s_flags |= MS_I_VERSION; > sb->s_iflags |= SB_I_CGROUPWB; > + > + err = super_setup_bdi(sb); > + if (err) { > + btrfs_err(fs_info, "super_setup_bdi failed"); > + return err; > + } > + > err = open_ctree(sb, fs_devices, (char *)data); > if (err) { > btrfs_err(fs_info, "open_ctree failed"); > -- > 2.10.2 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 08/24] btrfs: Convert to separately allocated bdi 2017-02-02 17:34 ` [PATCH 08/24] btrfs: Convert to separately allocated bdi Jan Kara 2017-02-03 18:33 ` Liu Bo @ 2017-02-08 15:22 ` David Sterba 1 sibling, 0 replies; 10+ messages in thread From: David Sterba @ 2017-02-08 15:22 UTC (permalink / raw) To: Jan Kara Cc: linux-fsdevel, Christoph Hellwig, linux-block, Chris Mason, Josef Bacik, David Sterba, linux-btrfs On Thu, Feb 02, 2017 at 06:34:06PM +0100, Jan Kara wrote: > Allocate struct backing_dev_info separately instead of embedding it > inside superblock. This unifies handling of bdi among users. > > CC: Chris Mason <clm@fb.com> > CC: Josef Bacik <jbacik@fb.com> > CC: David Sterba <dsterba@suse.com> > CC: linux-btrfs@vger.kernel.org > Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: David Sterba <dsterba@suse.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-02-09 13:03 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-02-02 17:33 [PATCH 0/24 RFC] fs: Convert all embedded bdis into separate ones Jan Kara 2017-02-02 17:34 ` [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems Jan Kara 2017-02-02 19:28 ` Liu Bo 2017-02-03 13:50 ` Jan Kara 2017-02-03 18:31 ` Liu Bo 2017-02-08 0:38 ` [lustre-devel] " Dilger, Andreas 2017-02-09 12:12 ` Jan Kara 2017-02-02 17:34 ` [PATCH 08/24] btrfs: Convert to separately allocated bdi Jan Kara 2017-02-03 18:33 ` Liu Bo 2017-02-08 15:22 ` David Sterba
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).