Skip to content

Commit

Permalink
Linux 4.12 compat: fix super_setup_bdi_name() call
Browse files Browse the repository at this point in the history
Provide a format parameter to super_setup_bdi_name() so we don't
create duplicate names in '/devices/virtual/bdi' sysfs namespace which
would prevent us from mounting more than one ZFS filesystem at a time.

Reviewed-by: Chunwei Chen <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #6147
  • Loading branch information
loli10K authored and tonyhutter committed Jun 9, 2017
1 parent 21fd04e commit cb8210d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 5 additions & 4 deletions include/linux/vfs_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ truncate_setsize(struct inode *ip, loff_t new)
* 4.12 - x.y, super_setup_bdi_name() new interface.
*/
#if defined(HAVE_SUPER_SETUP_BDI_NAME)
extern atomic_long_t zfs_bdi_seq;

static inline int
zpl_bdi_setup(struct super_block *sb, char *name)
{
return (super_setup_bdi_name(sb, name));
return super_setup_bdi_name(sb, "%.28s-%ld", name,
atomic_long_inc_return(&zfs_bdi_seq));
}
static inline void
zpl_bdi_destroy(struct super_block *sb)
Expand Down Expand Up @@ -143,7 +146,6 @@ static inline int
zpl_bdi_setup(struct super_block *sb, char *name)
{
struct backing_dev_info *bdi;
char tmp[32];
int error;

bdi = kmem_zalloc(sizeof (struct backing_dev_info), KM_SLEEP);
Expand All @@ -156,8 +158,7 @@ zpl_bdi_setup(struct super_block *sb, char *name)
return (error);
}

sprintf(tmp, "%.28s%s", name, "-%d");
error = bdi_register(bdi, NULL, tmp,
error = bdi_register(bdi, NULL, "%.28s-%ld", name,
atomic_long_inc_return(&zfs_bdi_seq));
if (error) {
bdi_destroy(bdi);
Expand Down
3 changes: 1 addition & 2 deletions module/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,7 @@ zfs_sb_teardown(zfs_sb_t *zsb, boolean_t unmounting)
}
EXPORT_SYMBOL(zfs_sb_teardown);

#if !defined(HAVE_SUPER_SETUP_BDI_NAME) && \
!defined(HAVE_2ARGS_BDI_SETUP_AND_REGISTER) && \
#if !defined(HAVE_2ARGS_BDI_SETUP_AND_REGISTER) && \
!defined(HAVE_3ARGS_BDI_SETUP_AND_REGISTER)
atomic_long_t zfs_bdi_seq = ATOMIC_LONG_INIT(0);
#endif
Expand Down

0 comments on commit cb8210d

Please sign in to comment.