mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 12:53:04 -04:00
bcachefs: journal path now uses discard_opt_enabled()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@@ -1798,19 +1798,6 @@ struct discard_buckets_state {
|
||||
u64 discarded;
|
||||
};
|
||||
|
||||
/*
|
||||
* This is needed because discard is both a filesystem option and a device
|
||||
* option, and mount options are supposed to apply to that mount and not be
|
||||
* persisted, i.e. if it's set as a mount option we can't propagate it to the
|
||||
* device.
|
||||
*/
|
||||
static inline bool discard_opt_enabled(struct bch_fs *c, struct bch_dev *ca)
|
||||
{
|
||||
return test_bit(BCH_FS_discard_mount_opt_set, &c->flags)
|
||||
? c->opts.discard
|
||||
: ca->mi.discard;
|
||||
}
|
||||
|
||||
static int bch2_discard_one_bucket(struct btree_trans *trans,
|
||||
struct bch_dev *ca,
|
||||
struct btree_iter *need_discard_iter,
|
||||
@@ -1874,7 +1861,7 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
|
||||
s->discarded++;
|
||||
*discard_pos_done = iter.pos;
|
||||
|
||||
if (discard_opt_enabled(c, ca) && !c->opts.nochanges) {
|
||||
if (bch2_discard_opt_enabled(c, ca) && !c->opts.nochanges) {
|
||||
/*
|
||||
* This works without any other locks because this is the only
|
||||
* thread that removes items from the need_discard tree
|
||||
|
||||
@@ -452,6 +452,7 @@ BCH_DEBUG_PARAMS_ALL()
|
||||
x(btree_node_compact) \
|
||||
x(btree_node_merge) \
|
||||
x(btree_node_sort) \
|
||||
x(btree_node_get) \
|
||||
x(btree_node_read) \
|
||||
x(btree_node_read_done) \
|
||||
x(btree_node_write) \
|
||||
@@ -459,6 +460,10 @@ BCH_DEBUG_PARAMS_ALL()
|
||||
x(btree_interior_update_total) \
|
||||
x(btree_gc) \
|
||||
x(data_write) \
|
||||
x(data_write_to_submit) \
|
||||
x(data_write_to_queue) \
|
||||
x(data_write_to_btree_update) \
|
||||
x(data_write_btree_update) \
|
||||
x(data_read) \
|
||||
x(data_promote) \
|
||||
x(journal_flush_write) \
|
||||
@@ -1272,4 +1277,17 @@ static inline unsigned data_replicas_required(struct bch_fs *c)
|
||||
#define BKEY_PADDED_ONSTACK(key, pad) \
|
||||
struct { struct bkey_i key; __u64 key ## _pad[pad]; }
|
||||
|
||||
/*
|
||||
* This is needed because discard is both a filesystem option and a device
|
||||
* option, and mount options are supposed to apply to that mount and not be
|
||||
* persisted, i.e. if it's set as a mount option we can't propagate it to the
|
||||
* device.
|
||||
*/
|
||||
static inline bool bch2_discard_opt_enabled(struct bch_fs *c, struct bch_dev *ca)
|
||||
{
|
||||
return test_bit(BCH_FS_discard_mount_opt_set, &c->flags)
|
||||
? c->opts.discard
|
||||
: ca->mi.discard;
|
||||
}
|
||||
|
||||
#endif /* _BCACHEFS_H */
|
||||
|
||||
@@ -300,7 +300,7 @@ void bch2_journal_do_discards(struct journal *j)
|
||||
|
||||
while (should_discard_bucket(j, ja)) {
|
||||
if (!c->opts.nochanges &&
|
||||
ca->mi.discard &&
|
||||
bch2_discard_opt_enabled(c, ca) &&
|
||||
bdev_max_discard_sectors(ca->disk_sb.bdev))
|
||||
blkdev_issue_discard(ca->disk_sb.bdev,
|
||||
bucket_to_sector(ca,
|
||||
@@ -701,6 +701,7 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct, bool kicked)
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
/* XXX shove journal discards off to another thread */
|
||||
bch2_journal_do_discards(j);
|
||||
|
||||
seq_to_flush = journal_seq_to_flush(j);
|
||||
|
||||
Reference in New Issue
Block a user