* [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
` (2 more replies)
0 siblings, 3 replies; 14+ 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] 14+ 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 14/24] mtd: Convert to dynamically allocated bdi infrastructure Jan Kara
2017-02-02 17:34 ` [PATCH 22/24] ubifs: Convert to separately allocated bdi Jan Kara
2 siblings, 2 replies; 14+ 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] 14+ messages in thread
* [PATCH 14/24] mtd: Convert to dynamically allocated bdi infrastructure
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-02 17:34 ` [PATCH 22/24] ubifs: Convert to separately allocated bdi Jan Kara
2 siblings, 0 replies; 14+ messages in thread
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel
Cc: Christoph Hellwig, linux-block, Jan Kara, David Woodhouse,
Brian Norris, linux-mtd
MTD already allocates backing_dev_info dynamically. Convert it to use
generic infrastructure for this including proper refcounting. We drop
mtd->backing_dev_info as its only use was to pass mtd_bdi pointer from
one file into another and if we wanted to keep that in a clean way, we'd
have to make mtd hold and drop bdi reference as needed which seems
pointless for passing one global pointer...
CC: David Woodhouse <dwmw2@infradead.org>
CC: Brian Norris <computersforpeace@gmail.com>
CC: linux-mtd@lists.infradead.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
drivers/mtd/mtdcore.c | 23 ++++++++++++-----------
drivers/mtd/mtdsuper.c | 7 ++++++-
include/linux/mtd/mtd.h | 5 -----
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 052772f7caef..a05063de362f 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -46,7 +46,7 @@
#include "mtdcore.h"
-static struct backing_dev_info *mtd_bdi;
+struct backing_dev_info *mtd_bdi;
#ifdef CONFIG_PM_SLEEP
@@ -496,11 +496,9 @@ int add_mtd_device(struct mtd_info *mtd)
* mtd_device_parse_register() multiple times on the same master MTD,
* especially with CONFIG_MTD_PARTITIONED_MASTER=y.
*/
- if (WARN_ONCE(mtd->backing_dev_info, "MTD already registered\n"))
+ if (WARN_ONCE(mtd->dev.type, "MTD already registered\n"))
return -EEXIST;
- mtd->backing_dev_info = mtd_bdi;
-
BUG_ON(mtd->writesize == 0);
mutex_lock(&mtd_table_mutex);
@@ -1775,13 +1773,18 @@ static struct backing_dev_info * __init mtd_bdi_init(char *name)
struct backing_dev_info *bdi;
int ret;
- bdi = kzalloc(sizeof(*bdi), GFP_KERNEL);
+ bdi = bdi_alloc(GFP_KERNEL);
if (!bdi)
return ERR_PTR(-ENOMEM);
- ret = bdi_setup_and_register(bdi, name);
+ bdi->name = name;
+ /*
+ * We put '-0' suffix to the name to get the same name format as we
+ * used to get. Since this is called only once, we get a unique name.
+ */
+ ret = bdi_register(bdi, NULL, "%.28s-0", name);
if (ret)
- kfree(bdi);
+ bdi_put(bdi);
return ret ? ERR_PTR(ret) : bdi;
}
@@ -1813,8 +1816,7 @@ static int __init init_mtd(void)
out_procfs:
if (proc_mtd)
remove_proc_entry("mtd", NULL);
- bdi_destroy(mtd_bdi);
- kfree(mtd_bdi);
+ bdi_put(mtd_bdi);
err_bdi:
class_unregister(&mtd_class);
err_reg:
@@ -1828,8 +1830,7 @@ static void __exit cleanup_mtd(void)
if (proc_mtd)
remove_proc_entry("mtd", NULL);
class_unregister(&mtd_class);
- bdi_destroy(mtd_bdi);
- kfree(mtd_bdi);
+ bdi_put(mtd_bdi);
idr_destroy(&mtd_idr);
}
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index 20c02a3b7417..e69e7855e31f 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -18,6 +18,7 @@
#include <linux/ctype.h>
#include <linux/slab.h>
#include <linux/major.h>
+#include <linux/backing-dev.h>
/*
* compare superblocks to see if they're equivalent
@@ -38,6 +39,8 @@ static int get_sb_mtd_compare(struct super_block *sb, void *_mtd)
return 0;
}
+extern struct backing_dev_info *mtd_bdi;
+
/*
* mark the superblock by the MTD device it is using
* - set the device number to be the correct MTD block device for pesuperstence
@@ -49,7 +52,9 @@ static int get_sb_mtd_set(struct super_block *sb, void *_mtd)
sb->s_mtd = mtd;
sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
- sb->s_bdi = mtd->backing_dev_info;
+ sb->s_bdi = bdi_get(mtd_bdi);
+ sb->s_iflags |= SB_I_DYNBDI;
+
return 0;
}
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 13f8052b9ff9..de64f87abbe0 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -332,11 +332,6 @@ struct mtd_info {
int (*_get_device) (struct mtd_info *mtd);
void (*_put_device) (struct mtd_info *mtd);
- /* Backing device capabilities for this device
- * - provides mmap capabilities
- */
- struct backing_dev_info *backing_dev_info;
-
struct notifier_block reboot_notifier; /* default mode before reboot */
/* ECC status information */
--
2.10.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 22/24] ubifs: 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 ` [PATCH 14/24] mtd: Convert to dynamically allocated bdi infrastructure Jan Kara
@ 2017-02-02 17:34 ` Jan Kara
2017-02-02 20:34 ` Richard Weinberger
2017-02-08 11:24 ` Richard Weinberger
2 siblings, 2 replies; 14+ messages in thread
From: Jan Kara @ 2017-02-02 17:34 UTC (permalink / raw)
To: linux-fsdevel
Cc: Christoph Hellwig, linux-block, Jan Kara, Richard Weinberger,
Artem Bityutskiy, Adrian Hunter, linux-mtd
Allocate struct backing_dev_info separately instead of embedding it
inside the superblock. This unifies handling of bdi among users.
CC: Richard Weinberger <richard@nod.at>
CC: Artem Bityutskiy <dedekind1@gmail.com>
CC: Adrian Hunter <adrian.hunter@intel.com>
CC: linux-mtd@lists.infradead.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ubifs/super.c | 23 +++++++----------------
fs/ubifs/ubifs.h | 3 ---
2 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index e08aa04fc835..34810eb52b22 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1827,7 +1827,6 @@ static void ubifs_put_super(struct super_block *sb)
}
ubifs_umount(c);
- bdi_destroy(&c->bdi);
ubi_close_volume(c->ubi);
mutex_unlock(&c->umount_mutex);
}
@@ -2019,29 +2018,23 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
goto out;
}
+ err = ubifs_parse_options(c, data, 0);
+ if (err)
+ goto out_close;
+
/*
* UBIFS provides 'backing_dev_info' in order to disable read-ahead. For
* UBIFS, I/O is not deferred, it is done immediately in readpage,
* which means the user would have to wait not just for their own I/O
* but the read-ahead I/O as well i.e. completely pointless.
*
- * Read-ahead will be disabled because @c->bdi.ra_pages is 0.
+ * Read-ahead will be disabled because @sb->s_bdi->ra_pages is 0.
*/
- c->bdi.name = "ubifs",
- c->bdi.capabilities = 0;
- err = bdi_init(&c->bdi);
+ err = super_setup_bdi_name(sb, "ubifs_%d_%d", c->vi.ubi_num,
+ c->vi.vol_id);
if (err)
goto out_close;
- err = bdi_register(&c->bdi, NULL, "ubifs_%d_%d",
- c->vi.ubi_num, c->vi.vol_id);
- if (err)
- goto out_bdi;
-
- err = ubifs_parse_options(c, data, 0);
- if (err)
- goto out_bdi;
- sb->s_bdi = &c->bdi;
sb->s_fs_info = c;
sb->s_magic = UBIFS_SUPER_MAGIC;
sb->s_blocksize = UBIFS_BLOCK_SIZE;
@@ -2080,8 +2073,6 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
ubifs_umount(c);
out_unlock:
mutex_unlock(&c->umount_mutex);
-out_bdi:
- bdi_destroy(&c->bdi);
out_close:
ubi_close_volume(c->ubi);
out:
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index ca72382ce6cc..41b42a425b42 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -968,7 +968,6 @@ struct ubifs_debug_info;
* struct ubifs_info - UBIFS file-system description data structure
* (per-superblock).
* @vfs_sb: VFS @struct super_block object
- * @bdi: backing device info object to make VFS happy and disable read-ahead
*
* @highest_inum: highest used inode number
* @max_sqnum: current global sequence number
@@ -1216,7 +1215,6 @@ struct ubifs_debug_info;
*/
struct ubifs_info {
struct super_block *vfs_sb;
- struct backing_dev_info bdi;
ino_t highest_inum;
unsigned long long max_sqnum;
@@ -1457,7 +1455,6 @@ extern const struct inode_operations ubifs_file_inode_operations;
extern const struct file_operations ubifs_dir_operations;
extern const struct inode_operations ubifs_dir_inode_operations;
extern const struct inode_operations ubifs_symlink_inode_operations;
-extern struct backing_dev_info ubifs_backing_dev_info;
extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
/* io.c */
--
2.10.2
^ permalink raw reply related [flat|nested] 14+ 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; 14+ 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] 14+ messages in thread
* Re: [PATCH 22/24] ubifs: Convert to separately allocated bdi
2017-02-02 17:34 ` [PATCH 22/24] ubifs: Convert to separately allocated bdi Jan Kara
@ 2017-02-02 20:34 ` Richard Weinberger
2017-02-03 13:45 ` Jan Kara
2017-02-08 11:24 ` Richard Weinberger
1 sibling, 1 reply; 14+ messages in thread
From: Richard Weinberger @ 2017-02-02 20:34 UTC (permalink / raw)
To: Jan Kara, linux-fsdevel
Cc: Christoph Hellwig, linux-block, Artem Bityutskiy, Adrian Hunter,
linux-mtd
Jan,
Am 02.02.2017 um 18:34 schrieb Jan Kara:
> Allocate struct backing_dev_info separately instead of embedding it
> inside the superblock. This unifies handling of bdi among users.
>
> CC: Richard Weinberger <richard@nod.at>
> CC: Artem Bityutskiy <dedekind1@gmail.com>
> CC: Adrian Hunter <adrian.hunter@intel.com>
> CC: linux-mtd@lists.infradead.org
> Signed-off-by: Jan Kara <jack@suse.cz>
Is this series available at some git tree, please?
Thanks,
//richard
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 22/24] ubifs: Convert to separately allocated bdi
2017-02-02 20:34 ` Richard Weinberger
@ 2017-02-03 13:45 ` Jan Kara
0 siblings, 0 replies; 14+ messages in thread
From: Jan Kara @ 2017-02-03 13:45 UTC (permalink / raw)
To: Richard Weinberger
Cc: Jan Kara, linux-fsdevel, Christoph Hellwig, linux-block,
Artem Bityutskiy, Adrian Hunter, linux-mtd
On Thu 02-02-17 21:34:32, Richard Weinberger wrote:
> Jan,
>
> Am 02.02.2017 um 18:34 schrieb Jan Kara:
> > Allocate struct backing_dev_info separately instead of embedding it
> > inside the superblock. This unifies handling of bdi among users.
> >
> > CC: Richard Weinberger <richard@nod.at>
> > CC: Artem Bityutskiy <dedekind1@gmail.com>
> > CC: Adrian Hunter <adrian.hunter@intel.com>
> > CC: linux-mtd@lists.infradead.org
> > Signed-off-by: Jan Kara <jack@suse.cz>
>
> Is this series available at some git tree, please?
I've pushed it out to:
git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git bdi
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ messages in thread
* Re: [PATCH 22/24] ubifs: Convert to separately allocated bdi
2017-02-02 17:34 ` [PATCH 22/24] ubifs: Convert to separately allocated bdi Jan Kara
2017-02-02 20:34 ` Richard Weinberger
@ 2017-02-08 11:24 ` Richard Weinberger
2017-02-09 12:17 ` Jan Kara
1 sibling, 1 reply; 14+ messages in thread
From: Richard Weinberger @ 2017-02-08 11:24 UTC (permalink / raw)
To: Jan Kara, linux-fsdevel
Cc: Christoph Hellwig, linux-block, Artem Bityutskiy, Adrian Hunter,
linux-mtd
Am 02.02.2017 um 18:34 schrieb Jan Kara:
> Allocate struct backing_dev_info separately instead of embedding it
> inside the superblock. This unifies handling of bdi among users.
>
> CC: Richard Weinberger <richard@nod.at>
> CC: Artem Bityutskiy <dedekind1@gmail.com>
> CC: Adrian Hunter <adrian.hunter@intel.com>
> CC: linux-mtd@lists.infradead.org
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/ubifs/super.c | 23 +++++++----------------
> fs/ubifs/ubifs.h | 3 ---
> 2 files changed, 7 insertions(+), 19 deletions(-)
>
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index e08aa04fc835..34810eb52b22 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -1827,7 +1827,6 @@ static void ubifs_put_super(struct super_block *sb)
> }
>
> ubifs_umount(c);
> - bdi_destroy(&c->bdi);
> ubi_close_volume(c->ubi);
> mutex_unlock(&c->umount_mutex);
> }
> @@ -2019,29 +2018,23 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
> goto out;
> }
>
> + err = ubifs_parse_options(c, data, 0);
> + if (err)
> + goto out_close;
> +
> /*
> * UBIFS provides 'backing_dev_info' in order to disable read-ahead. For
> * UBIFS, I/O is not deferred, it is done immediately in readpage,
> * which means the user would have to wait not just for their own I/O
> * but the read-ahead I/O as well i.e. completely pointless.
> *
> - * Read-ahead will be disabled because @c->bdi.ra_pages is 0.
> + * Read-ahead will be disabled because @sb->s_bdi->ra_pages is 0.
> */
> - c->bdi.name = "ubifs",
> - c->bdi.capabilities = 0;
So ->capabilities is now zero by default since you use __GFP_ZERO in
bdi_alloc().
At least for UBIFS I'll add a comment on this, otherwise it is not so
clear that UBIFS wants a BDI with no capabilities and how it achieves that.
Acked-by: Richard Weinberger <richard@nod.at>
Thanks,
//richard
^ permalink raw reply [flat|nested] 14+ 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; 14+ 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] 14+ messages in thread
* Re: [PATCH 22/24] ubifs: Convert to separately allocated bdi
2017-02-08 11:24 ` Richard Weinberger
@ 2017-02-09 12:17 ` Jan Kara
2017-02-09 14:56 ` Richard Weinberger
0 siblings, 1 reply; 14+ messages in thread
From: Jan Kara @ 2017-02-09 12:17 UTC (permalink / raw)
To: Richard Weinberger
Cc: Jan Kara, linux-fsdevel, Christoph Hellwig, linux-block,
Artem Bityutskiy, Adrian Hunter, linux-mtd
On Wed 08-02-17 12:24:00, Richard Weinberger wrote:
> Am 02.02.2017 um 18:34 schrieb Jan Kara:
> > Allocate struct backing_dev_info separately instead of embedding it
> > inside the superblock. This unifies handling of bdi among users.
> >
> > CC: Richard Weinberger <richard@nod.at>
> > CC: Artem Bityutskiy <dedekind1@gmail.com>
> > CC: Adrian Hunter <adrian.hunter@intel.com>
> > CC: linux-mtd@lists.infradead.org
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> > fs/ubifs/super.c | 23 +++++++----------------
> > fs/ubifs/ubifs.h | 3 ---
> > 2 files changed, 7 insertions(+), 19 deletions(-)
> >
> > diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> > index e08aa04fc835..34810eb52b22 100644
> > --- a/fs/ubifs/super.c
> > +++ b/fs/ubifs/super.c
> > @@ -1827,7 +1827,6 @@ static void ubifs_put_super(struct super_block *sb)
> > }
> >
> > ubifs_umount(c);
> > - bdi_destroy(&c->bdi);
> > ubi_close_volume(c->ubi);
> > mutex_unlock(&c->umount_mutex);
> > }
> > @@ -2019,29 +2018,23 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
> > goto out;
> > }
> >
> > + err = ubifs_parse_options(c, data, 0);
> > + if (err)
> > + goto out_close;
> > +
> > /*
> > * UBIFS provides 'backing_dev_info' in order to disable read-ahead. For
> > * UBIFS, I/O is not deferred, it is done immediately in readpage,
> > * which means the user would have to wait not just for their own I/O
> > * but the read-ahead I/O as well i.e. completely pointless.
> > *
> > - * Read-ahead will be disabled because @c->bdi.ra_pages is 0.
> > + * Read-ahead will be disabled because @sb->s_bdi->ra_pages is 0.
> > */
> > - c->bdi.name = "ubifs",
> > - c->bdi.capabilities = 0;
>
> So ->capabilities is now zero by default since you use __GFP_ZERO in
> bdi_alloc().
> At least for UBIFS I'll add a comment on this, otherwise it is not so
> clear that UBIFS wants a BDI with no capabilities and how it achieves that.
OK, I've modified the comment to:
* Read-ahead will be disabled because @sb->s_bdi->ra_pages is 0. Also
* @sb->s_bdi->capabilities are initialized to 0 so there won't be any
* writeback happening.
*/
> Acked-by: Richard Weinberger <richard@nod.at>
Thanks.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 22/24] ubifs: Convert to separately allocated bdi
2017-02-09 12:17 ` Jan Kara
@ 2017-02-09 14:56 ` Richard Weinberger
0 siblings, 0 replies; 14+ messages in thread
From: Richard Weinberger @ 2017-02-09 14:56 UTC (permalink / raw)
To: Jan Kara
Cc: linux-fsdevel, Christoph Hellwig, linux-block, Artem Bityutskiy,
Adrian Hunter, linux-mtd
Am 09.02.2017 um 13:17 schrieb Jan Kara:
>> So ->capabilities is now zero by default since you use __GFP_ZERO in
>> bdi_alloc().
>> At least for UBIFS I'll add a comment on this, otherwise it is not so
>> clear that UBIFS wants a BDI with no capabilities and how it achieves that.
>
> OK, I've modified the comment to:
>
> * Read-ahead will be disabled because @sb->s_bdi->ra_pages is 0. Also
> * @sb->s_bdi->capabilities are initialized to 0 so there won't be any
> * writeback happening.
> */
Nice!
Thanks,
//richard
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2017-02-09 14:56 UTC | newest]
Thread overview: 14+ 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 14/24] mtd: Convert to dynamically allocated bdi infrastructure Jan Kara
2017-02-02 17:34 ` [PATCH 22/24] ubifs: Convert to separately allocated bdi 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
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).