This is going to be used in the bch_extent_rebalance improvements, which
propagate io_path options into the extent (important for rebalance,
which needs something present in the extent for transactionally tagging
them in the rebalance_work btree, and also for indirect extents).

By tracking in bch_extent_rebalance whether the option came from the
filesystem or the inode we can correctly handle options being changed on
indirect extents.

Signed-off-by: Kent Overstreet <[email protected]>
---
 fs/bcachefs/inode.c | 8 +++++++-
 fs/bcachefs/opts.h  | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c
index 3af6029ea9b7..62fcc3a0bf69 100644
--- a/fs/bcachefs/inode.c
+++ b/fs/bcachefs/inode.c
@@ -1142,7 +1142,13 @@ struct bch_opts bch2_inode_opts_to_opts(struct 
bch_inode_unpacked *inode)
 void bch2_inode_opts_get(struct bch_io_opts *opts, struct bch_fs *c,
                         struct bch_inode_unpacked *inode)
 {
-#define x(_name, _bits)                opts->_name = inode_opt_get(c, inode, 
_name);
+#define x(_name, _bits)                                                        
\
+       if ((inode)->bi_##_name) {                                      \
+               opts->_name = inode->bi_##_name - 1;                    \
+               opts->_name##_from_inode = true;                        \
+       } else {                                                        \
+               opts->_name = c->opts._name;                            \
+       }
        BCH_INODE_OPTS()
 #undef x
 
diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h
index 13555bc35f00..918eb6730117 100644
--- a/fs/bcachefs/opts.h
+++ b/fs/bcachefs/opts.h
@@ -624,6 +624,9 @@ struct bch_io_opts {
 #define x(_name, _bits)        u##_bits _name;
        BCH_INODE_OPTS()
 #undef x
+#define x(_name, _bits)        u64 _name##_from_inode:1;
+       BCH_INODE_OPTS()
+#undef x
 };
 
 static inline void bch2_io_opts_fixups(struct bch_io_opts *opts)
-- 
2.45.2


Reply via email to