summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-12-21 18:06:12 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2017-12-27 15:11:30 -0500
commitd5c5a2eb44e73f15ff8b03228853887621264730 (patch)
tree044717f98edaa922974356863fa15d5e5fa4bb86
parentaf8e18b0a779ed5103a2d13f59fd2fc4de1fe4a6 (diff)
bcachefs: fixes for building in userspace
-rw-r--r--fs/bcachefs/alloc.c3
-rw-r--r--fs/bcachefs/bcachefs.h8
-rw-r--r--fs/bcachefs/super-io.c11
-rw-r--r--fs/bcachefs/super-io.h13
-rw-r--r--fs/bcachefs/xattr.c6
5 files changed, 28 insertions, 13 deletions
diff --git a/fs/bcachefs/alloc.c b/fs/bcachefs/alloc.c
index 5c132c0f374a..29799df65dbc 100644
--- a/fs/bcachefs/alloc.c
+++ b/fs/bcachefs/alloc.c
@@ -1591,8 +1591,7 @@ void bch2_recalc_capacity(struct bch_fs *c)
ra_pages += bdi->ra_pages;
}
- if (c->vfs_sb)
- c->vfs_sb->s_bdi->ra_pages = ra_pages;
+ bch2_set_ra_pages(c, ra_pages);
/* Find fastest, slowest tiers with devices: */
diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h
index f5811ef57bdb..e25baf56f37f 100644
--- a/fs/bcachefs/bcachefs.h
+++ b/fs/bcachefs/bcachefs.h
@@ -709,6 +709,14 @@ struct bch_fs {
#undef BCH_TIME_STAT
};
+static inline void bch2_set_ra_pages(struct bch_fs *c, unsigned ra_pages)
+{
+#ifndef NO_BCACHEFS_FS
+ if (c->vfs_sb)
+ c->vfs_sb->s_bdi->ra_pages = ra_pages;
+#endif
+}
+
static inline bool bch2_fs_running(struct bch_fs *c)
{
return c->state == BCH_FS_RO || c->state == BCH_FS_RW;
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index 7af4f37fdae6..3f55c244c639 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -1117,17 +1117,6 @@ int bch2_replicas_gc_start(struct bch_fs *c, unsigned typemask)
/* Replicas tracking - superblock: */
-static inline struct bch_replicas_entry *
-replicas_entry_next(struct bch_replicas_entry *i)
-{
- return (void *) i + offsetof(struct bch_replicas_entry, devs) + i->nr;
-}
-
-#define for_each_replicas_entry(_r, _i) \
- for (_i = (_r)->entries; \
- (void *) (_i) < vstruct_end(&(_r)->field) && (_i)->data_type;\
- (_i) = replicas_entry_next(_i))
-
static void bch2_sb_replicas_nr_entries(struct bch_sb_field_replicas *r,
unsigned *nr,
unsigned *bytes,
diff --git a/fs/bcachefs/super-io.h b/fs/bcachefs/super-io.h
index 725d2f1487ec..4096efb22d26 100644
--- a/fs/bcachefs/super-io.h
+++ b/fs/bcachefs/super-io.h
@@ -150,4 +150,17 @@ unsigned bch2_dev_has_data(struct bch_fs *, struct bch_dev *);
int bch2_replicas_gc_end(struct bch_fs *, int);
int bch2_replicas_gc_start(struct bch_fs *, unsigned);
+/* iterate over superblock replicas - used by userspace tools: */
+
+static inline struct bch_replicas_entry *
+replicas_entry_next(struct bch_replicas_entry *i)
+{
+ return (void *) i + offsetof(struct bch_replicas_entry, devs) + i->nr;
+}
+
+#define for_each_replicas_entry(_r, _i) \
+ for (_i = (_r)->entries; \
+ (void *) (_i) < vstruct_end(&(_r)->field) && (_i)->data_type;\
+ (_i) = replicas_entry_next(_i))
+
#endif /* _BCACHEFS_SUPER_IO_H */
diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
index 823a6cbd72c0..1d6cbe72e05b 100644
--- a/fs/bcachefs/xattr.c
+++ b/fs/bcachefs/xattr.c
@@ -359,6 +359,8 @@ static const struct xattr_handler bch_xattr_security_handler = {
.flags = BCH_XATTR_INDEX_SECURITY,
};
+#ifndef NO_BCACHEFS_FS
+
static int bch2_xattr_bcachefs_get(const struct xattr_handler *handler,
struct dentry *dentry, struct inode *vinode,
const char *name, void *buffer, size_t size)
@@ -466,13 +468,17 @@ static const struct xattr_handler bch_xattr_bcachefs_handler = {
.set = bch2_xattr_bcachefs_set,
};
+#endif /* NO_BCACHEFS_FS */
+
const struct xattr_handler *bch2_xattr_handlers[] = {
&bch_xattr_user_handler,
&posix_acl_access_xattr_handler,
&posix_acl_default_xattr_handler,
&bch_xattr_trusted_handler,
&bch_xattr_security_handler,
+#ifndef NO_BCACHEFS_FS
&bch_xattr_bcachefs_handler,
+#endif
NULL
};