summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-11-07 16:39:03 -0800
committerBrian Behlendorf <[email protected]>2011-11-08 10:19:03 -0800
commit5547c2f1bf49802835fd6c52f15115ba344a2a8b (patch)
tree7e2314465d7a0ad5b6922c1d385b6c8ffa4e7979 /include
parent591fb62f19ee2431983a4cbeb0d200b1b8e7daf5 (diff)
Simplify BDI integration
Update the code to use the bdi_setup_and_register() helper to simplify the bdi integration code. The updated code now just registers the bdi during mount and destroys it during unmount. The only complication is that for 2.6.32 - 2.6.33 kernels the helper wasn't available so in these cases the zfs code must provide it. Luckily the bdi_setup_and_register() function is trivial. Signed-off-by: Brian Behlendorf <[email protected]> Closes #367
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.in1
-rw-r--r--include/linux/Makefile.in1
-rw-r--r--include/linux/vfs_compat.h45
-rw-r--r--include/sys/Makefile.in1
-rw-r--r--include/sys/fm/Makefile.in1
-rw-r--r--include/sys/fm/fs/Makefile.in1
-rw-r--r--include/sys/fs/Makefile.in1
7 files changed, 35 insertions, 16 deletions
diff --git a/include/Makefile.in b/include/Makefile.in
index de3af33ec..5614daa0e 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/always-no-unused-but-set-variable.m4 \
$(top_srcdir)/config/kernel-bdev-block-device-operations.m4 \
$(top_srcdir)/config/kernel-bdev-logical-size.m4 \
+ $(top_srcdir)/config/kernel-bdi-setup-and-register.m4 \
$(top_srcdir)/config/kernel-bdi.m4 \
$(top_srcdir)/config/kernel-bio-empty-barrier.m4 \
$(top_srcdir)/config/kernel-bio-end-io-t-args.m4 \
diff --git a/include/linux/Makefile.in b/include/linux/Makefile.in
index 7e65511a6..2666d4f91 100644
--- a/include/linux/Makefile.in
+++ b/include/linux/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/always-no-unused-but-set-variable.m4 \
$(top_srcdir)/config/kernel-bdev-block-device-operations.m4 \
$(top_srcdir)/config/kernel-bdev-logical-size.m4 \
+ $(top_srcdir)/config/kernel-bdi-setup-and-register.m4 \
$(top_srcdir)/config/kernel-bdi.m4 \
$(top_srcdir)/config/kernel-bio-empty-barrier.m4 \
$(top_srcdir)/config/kernel-bio-end-io-t-args.m4 \
diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h
index cbbf21e61..825a7fd3b 100644
--- a/include/linux/vfs_compat.h
+++ b/include/linux/vfs_compat.h
@@ -62,23 +62,36 @@ truncate_setsize(struct inode *ip, loff_t new)
}
#endif /* HAVE_TRUNCATE_SETSIZE */
+#if defined(HAVE_BDI) && !defined(HAVE_BDI_SETUP_AND_REGISTER)
/*
- * 2.6.32 API change,
- * Added backing_device_info (bdi) per super block interfaces. When
- * available a bdi must be configured when using a non-device backed
- * filesystem for proper writeback. It's safe to leave this code
- * dormant for kernels which only support pdflush and not bdi.
+ * 2.6.34 API change,
+ * Add bdi_setup_and_register() function if not yet provided by kernel.
+ * It is used to quickly initialize and register a BDI for the filesystem.
*/
-#ifdef HAVE_BDI
-#define bdi_get_sb(sb) (sb->s_bdi)
-#define bdi_put_sb(sb, bdi) (sb->s_bdi = bdi)
-#else
-#define bdi_init(bdi) (0)
-#define bdi_destroy(bdi) (0)
-#define bdi_register(bdi, parent, fmt, args) (0)
-#define bdi_unregister(bdi) (0)
-#define bdi_get_sb(sb) (0)
-#define bdi_put_sb(sb, bdi) (0)
-#endif /* HAVE_BDI */
+extern atomic_long_t zfs_bdi_seq;
+
+static inline int
+bdi_setup_and_register(struct backing_dev_info *bdi,char *name,unsigned int cap)
+{
+ char tmp[32];
+ int error;
+
+ bdi->name = name;
+ bdi->capabilities = cap;
+ error = bdi_init(bdi);
+ if (error)
+ 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);
+ return (error);
+ }
+
+ return (error);
+}
+#endif /* HAVE_BDI && !HAVE_BDI_SETUP_AND_REGISTER */
#endif /* _ZFS_VFS_H */
diff --git a/include/sys/Makefile.in b/include/sys/Makefile.in
index 6adc1ee5a..0a5ecc39f 100644
--- a/include/sys/Makefile.in
+++ b/include/sys/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/always-no-unused-but-set-variable.m4 \
$(top_srcdir)/config/kernel-bdev-block-device-operations.m4 \
$(top_srcdir)/config/kernel-bdev-logical-size.m4 \
+ $(top_srcdir)/config/kernel-bdi-setup-and-register.m4 \
$(top_srcdir)/config/kernel-bdi.m4 \
$(top_srcdir)/config/kernel-bio-empty-barrier.m4 \
$(top_srcdir)/config/kernel-bio-end-io-t-args.m4 \
diff --git a/include/sys/fm/Makefile.in b/include/sys/fm/Makefile.in
index 036fd47a3..7791750fa 100644
--- a/include/sys/fm/Makefile.in
+++ b/include/sys/fm/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/always-no-unused-but-set-variable.m4 \
$(top_srcdir)/config/kernel-bdev-block-device-operations.m4 \
$(top_srcdir)/config/kernel-bdev-logical-size.m4 \
+ $(top_srcdir)/config/kernel-bdi-setup-and-register.m4 \
$(top_srcdir)/config/kernel-bdi.m4 \
$(top_srcdir)/config/kernel-bio-empty-barrier.m4 \
$(top_srcdir)/config/kernel-bio-end-io-t-args.m4 \
diff --git a/include/sys/fm/fs/Makefile.in b/include/sys/fm/fs/Makefile.in
index 2cff6d665..ee4a8fda5 100644
--- a/include/sys/fm/fs/Makefile.in
+++ b/include/sys/fm/fs/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/always-no-unused-but-set-variable.m4 \
$(top_srcdir)/config/kernel-bdev-block-device-operations.m4 \
$(top_srcdir)/config/kernel-bdev-logical-size.m4 \
+ $(top_srcdir)/config/kernel-bdi-setup-and-register.m4 \
$(top_srcdir)/config/kernel-bdi.m4 \
$(top_srcdir)/config/kernel-bio-empty-barrier.m4 \
$(top_srcdir)/config/kernel-bio-end-io-t-args.m4 \
diff --git a/include/sys/fs/Makefile.in b/include/sys/fs/Makefile.in
index fd9c14662..9d3f79a1d 100644
--- a/include/sys/fs/Makefile.in
+++ b/include/sys/fs/Makefile.in
@@ -43,6 +43,7 @@ am__aclocal_m4_deps = \
$(top_srcdir)/config/always-no-unused-but-set-variable.m4 \
$(top_srcdir)/config/kernel-bdev-block-device-operations.m4 \
$(top_srcdir)/config/kernel-bdev-logical-size.m4 \
+ $(top_srcdir)/config/kernel-bdi-setup-and-register.m4 \
$(top_srcdir)/config/kernel-bdi.m4 \
$(top_srcdir)/config/kernel-bio-empty-barrier.m4 \
$(top_srcdir)/config/kernel-bio-end-io-t-args.m4 \