Linux 4.12 compat: super_setup_bdi_name()
All filesystems were converted to dynamically allocated BDIs. The destruction of backing_dev_info structures is handled as part of super block destruction. Refactor the code to abstract away the details of creating and destroying a BDI. Reviewed-by: Chunwei Chen <david.chen@osnexus.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #6089
This commit is contained in:
parent
a83a4f9d10
commit
e4cb6ee6a5
|
@ -1,38 +0,0 @@
|
|||
dnl #
|
||||
dnl # 2.6.32 - 2.6.33, bdi_setup_and_register() is not exported.
|
||||
dnl # 2.6.34 - 3.19, bdi_setup_and_register() takes 3 arguments.
|
||||
dnl # 4.0 - x.y, bdi_setup_and_register() takes 2 arguments.
|
||||
dnl #
|
||||
AC_DEFUN([ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER], [
|
||||
AC_MSG_CHECKING([whether bdi_setup_and_register() wants 2 args])
|
||||
ZFS_LINUX_TRY_COMPILE_SYMBOL([
|
||||
#include <linux/backing-dev.h>
|
||||
struct backing_dev_info bdi;
|
||||
], [
|
||||
char *name = "bdi";
|
||||
int error __attribute__((unused)) =
|
||||
bdi_setup_and_register(&bdi, name);
|
||||
], [bdi_setup_and_register], [mm/backing-dev.c], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_2ARGS_BDI_SETUP_AND_REGISTER, 1,
|
||||
[bdi_setup_and_register() wants 2 args])
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_CHECKING([whether bdi_setup_and_register() wants 3 args])
|
||||
ZFS_LINUX_TRY_COMPILE_SYMBOL([
|
||||
#include <linux/backing-dev.h>
|
||||
struct backing_dev_info bdi;
|
||||
], [
|
||||
char *name = "bdi";
|
||||
unsigned int cap = BDI_CAP_MAP_COPY;
|
||||
int error __attribute__((unused)) =
|
||||
bdi_setup_and_register(&bdi, name, cap);
|
||||
], [bdi_setup_and_register], [mm/backing-dev.c], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_3ARGS_BDI_SETUP_AND_REGISTER, 1,
|
||||
[bdi_setup_and_register() wants 3 args])
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
])
|
||||
])
|
|
@ -0,0 +1,56 @@
|
|||
dnl #
|
||||
dnl # 2.6.32 - 2.6.33, bdi_setup_and_register() is not exported.
|
||||
dnl # 2.6.34 - 3.19, bdi_setup_and_register() takes 3 arguments.
|
||||
dnl # 4.0 - 4.11, bdi_setup_and_register() takes 2 arguments.
|
||||
dnl # 4.12 - x.y, super_setup_bdi_name() new interface.
|
||||
dnl #
|
||||
AC_DEFUN([ZFS_AC_KERNEL_BDI], [
|
||||
AC_MSG_CHECKING([whether super_setup_bdi_name() exists])
|
||||
ZFS_LINUX_TRY_COMPILE_SYMBOL([
|
||||
#include <linux/fs.h>
|
||||
struct super_block sb;
|
||||
], [
|
||||
char *name = "bdi";
|
||||
int error __attribute__((unused)) =
|
||||
super_setup_bdi_name(&sb, name);
|
||||
], [super_setup_bdi_name], [fs/super.c], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_SUPER_SETUP_BDI_NAME, 1,
|
||||
[super_setup_bdi_name() exits])
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_CHECKING(
|
||||
[whether bdi_setup_and_register() wants 2 args])
|
||||
ZFS_LINUX_TRY_COMPILE_SYMBOL([
|
||||
#include <linux/backing-dev.h>
|
||||
struct backing_dev_info bdi;
|
||||
], [
|
||||
char *name = "bdi";
|
||||
int error __attribute__((unused)) =
|
||||
bdi_setup_and_register(&bdi, name);
|
||||
], [bdi_setup_and_register], [mm/backing-dev.c], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_2ARGS_BDI_SETUP_AND_REGISTER, 1,
|
||||
[bdi_setup_and_register() wants 2 args])
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_CHECKING(
|
||||
[whether bdi_setup_and_register() wants 3 args])
|
||||
ZFS_LINUX_TRY_COMPILE_SYMBOL([
|
||||
#include <linux/backing-dev.h>
|
||||
struct backing_dev_info bdi;
|
||||
], [
|
||||
char *name = "bdi";
|
||||
unsigned int cap = BDI_CAP_MAP_COPY;
|
||||
int error __attribute__((unused)) =
|
||||
bdi_setup_and_register(&bdi, name, cap);
|
||||
], [bdi_setup_and_register], [mm/backing-dev.c], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_3ARGS_BDI_SETUP_AND_REGISTER, 1,
|
||||
[bdi_setup_and_register() wants 3 args])
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
])
|
||||
])
|
||||
])
|
|
@ -96,7 +96,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
|
|||
ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
|
||||
ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD
|
||||
ZFS_AC_KERNEL_S_D_OP
|
||||
ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER
|
||||
ZFS_AC_KERNEL_BDI
|
||||
ZFS_AC_KERNEL_SET_NLINK
|
||||
ZFS_AC_KERNEL_ELEVATOR_CHANGE
|
||||
ZFS_AC_KERNEL_5ARG_SGET
|
||||
|
|
|
@ -69,45 +69,114 @@ truncate_setsize(struct inode *ip, loff_t new)
|
|||
/*
|
||||
* 2.6.32 - 2.6.33, bdi_setup_and_register() is not available.
|
||||
* 2.6.34 - 3.19, bdi_setup_and_register() takes 3 arguments.
|
||||
* 4.0 - x.y, bdi_setup_and_register() takes 2 arguments.
|
||||
* 4.0 - 4.11, bdi_setup_and_register() takes 2 arguments.
|
||||
* 4.12 - x.y, super_setup_bdi_name() new interface.
|
||||
*/
|
||||
#if defined(HAVE_2ARGS_BDI_SETUP_AND_REGISTER)
|
||||
#if defined(HAVE_SUPER_SETUP_BDI_NAME)
|
||||
static inline int
|
||||
zpl_bdi_setup_and_register(struct backing_dev_info *bdi, char *name)
|
||||
zpl_bdi_setup(struct super_block *sb, char *name)
|
||||
{
|
||||
return (bdi_setup_and_register(bdi, name));
|
||||
return (super_setup_bdi_name(sb, name));
|
||||
}
|
||||
static inline void
|
||||
zpl_bdi_destroy(struct super_block *sb)
|
||||
{
|
||||
}
|
||||
#elif defined(HAVE_2ARGS_BDI_SETUP_AND_REGISTER)
|
||||
static inline int
|
||||
zpl_bdi_setup(struct super_block *sb, char *name)
|
||||
{
|
||||
struct backing_dev_info *bdi;
|
||||
int error;
|
||||
|
||||
bdi = kmem_zalloc(sizeof (struct backing_dev_info), KM_SLEEP);
|
||||
error = bdi_setup_and_register(bdi, name);
|
||||
if (error) {
|
||||
kmem_free(bdi, sizeof (struct backing_dev_info));
|
||||
return (error);
|
||||
}
|
||||
|
||||
sb->s_bdi = bdi;
|
||||
|
||||
return (0);
|
||||
}
|
||||
static inline void
|
||||
zpl_bdi_destroy(struct super_block *sb)
|
||||
{
|
||||
struct backing_dev_info *bdi = sb->s_bdi;
|
||||
|
||||
bdi_destroy(bdi);
|
||||
kmem_free(bdi, sizeof (struct backing_dev_info));
|
||||
sb->s_bdi = NULL;
|
||||
}
|
||||
#elif defined(HAVE_3ARGS_BDI_SETUP_AND_REGISTER)
|
||||
static inline int
|
||||
zpl_bdi_setup_and_register(struct backing_dev_info *bdi, char *name)
|
||||
zpl_bdi_setup(struct super_block *sb, char *name)
|
||||
{
|
||||
return (bdi_setup_and_register(bdi, name, BDI_CAP_MAP_COPY));
|
||||
struct backing_dev_info *bdi;
|
||||
int error;
|
||||
|
||||
bdi = kmem_zalloc(sizeof (struct backing_dev_info), KM_SLEEP);
|
||||
error = bdi_setup_and_register(bdi, name, BDI_CAP_MAP_COPY);
|
||||
if (error) {
|
||||
kmem_free(sb->s_bdi, sizeof (struct backing_dev_info));
|
||||
return (error);
|
||||
}
|
||||
|
||||
sb->s_bdi = bdi;
|
||||
|
||||
return (0);
|
||||
}
|
||||
static inline void
|
||||
zpl_bdi_destroy(struct super_block *sb)
|
||||
{
|
||||
struct backing_dev_info *bdi = sb->s_bdi;
|
||||
|
||||
bdi_destroy(bdi);
|
||||
kmem_free(bdi, sizeof (struct backing_dev_info));
|
||||
sb->s_bdi = NULL;
|
||||
}
|
||||
#else
|
||||
extern atomic_long_t zfs_bdi_seq;
|
||||
|
||||
static inline int
|
||||
zpl_bdi_setup_and_register(struct backing_dev_info *bdi, char *name)
|
||||
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);
|
||||
bdi->name = name;
|
||||
bdi->capabilities = BDI_CAP_MAP_COPY;
|
||||
|
||||
error = bdi_init(bdi);
|
||||
if (error)
|
||||
if (error) {
|
||||
kmem_free(bdi, sizeof (struct backing_dev_info));
|
||||
return (error);
|
||||
}
|
||||
|
||||
sprintf(tmp, "%.28s%s", name, "-%d");
|
||||
error = bdi_register(bdi, NULL, tmp,
|
||||
atomic_long_inc_return(&zfs_bdi_seq));
|
||||
if (error) {
|
||||
bdi_destroy(bdi);
|
||||
kmem_free(bdi, sizeof (struct backing_dev_info));
|
||||
return (error);
|
||||
}
|
||||
|
||||
return (error);
|
||||
sb->s_bdi = bdi;
|
||||
|
||||
return (0);
|
||||
}
|
||||
static inline void
|
||||
zpl_bdi_destroy(struct super_block *sb)
|
||||
{
|
||||
struct backing_dev_info *bdi = sb->s_bdi;
|
||||
|
||||
bdi_destroy(bdi);
|
||||
kmem_free(bdi, sizeof (struct backing_dev_info));
|
||||
sb->s_bdi = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1374,7 +1374,8 @@ zfs_sb_teardown(zfs_sb_t *zsb, boolean_t unmounting)
|
|||
}
|
||||
EXPORT_SYMBOL(zfs_sb_teardown);
|
||||
|
||||
#if !defined(HAVE_2ARGS_BDI_SETUP_AND_REGISTER) && \
|
||||
#if !defined(HAVE_SUPER_SETUP_BDI_NAME) && \
|
||||
!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
|
||||
|
@ -1406,10 +1407,12 @@ zfs_domount(struct super_block *sb, zfs_mntopts_t *zmo, int silent)
|
|||
zsb->z_bdi.ra_pages = 0;
|
||||
sb->s_bdi = &zsb->z_bdi;
|
||||
|
||||
error = -zpl_bdi_setup_and_register(&zsb->z_bdi, "zfs");
|
||||
error = -zpl_bdi_setup(sb, "zfs");
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
sb->s_bdi->ra_pages = 0;
|
||||
|
||||
/* Set callback operations for the file system. */
|
||||
sb->s_op = &zpl_super_operations;
|
||||
sb->s_xattr = zpl_xattr_handlers;
|
||||
|
@ -1505,7 +1508,7 @@ zfs_umount(struct super_block *sb)
|
|||
arc_remove_prune_callback(zsb->z_arc_prune);
|
||||
VERIFY(zfs_sb_teardown(zsb, B_TRUE) == 0);
|
||||
os = zsb->z_os;
|
||||
bdi_destroy(sb->s_bdi);
|
||||
zpl_bdi_destroy(sb);
|
||||
|
||||
/*
|
||||
* z_os will be NULL if there was an error in
|
||||
|
|
Loading…
Reference in New Issue