From: Christoph Hellwig <hch@lst.de>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH 13/17] btrfs: add a btrfs_finish_ordered_extent helper
Date: Wed, 31 May 2023 09:54:06 +0200 [thread overview]
Message-ID: <20230531075410.480499-14-hch@lst.de> (raw)
In-Reply-To: <20230531075410.480499-1-hch@lst.de>
Add a helper to complete an ordered_extent without first doing a lookup.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/ordered-data.c | 20 ++++++++++++++++++++
fs/btrfs/ordered-data.h | 3 +++
include/trace/events/btrfs.h | 29 +++++++++++++++++++++++++++++
3 files changed, 52 insertions(+)
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 70f411412ca158..22571c6b7ff6f7 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -371,6 +371,26 @@ static void btrfs_queue_ordered_fn(struct btrfs_ordered_extent *ordered)
btrfs_queue_work(wq, &ordered->work);
}
+bool btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered,
+ struct page *page, u64 file_offset, u64 len,
+ bool uptodate)
+{
+ struct btrfs_inode *inode = BTRFS_I(ordered->inode);
+ unsigned long flags;
+ bool ret;
+
+ trace_btrfs_finish_ordered_extent(inode, file_offset, len, uptodate);
+
+ spin_lock_irqsave(&inode->ordered_tree.lock, flags);
+ ret = can_finish_ordered_extent(ordered, page, file_offset, len,
+ uptodate);
+ spin_unlock_irqrestore(&inode->ordered_tree.lock, flags);
+
+ if (ret)
+ btrfs_queue_ordered_fn(ordered);
+ return ret;
+}
+
/*
* Mark all ordered extents io inside the specified range finished.
*
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index 0bd0f036813298..173bd5c5df2624 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -167,6 +167,9 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);
void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry);
void btrfs_remove_ordered_extent(struct btrfs_inode *btrfs_inode,
struct btrfs_ordered_extent *entry);
+bool btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered,
+ struct page *page, u64 file_offset, u64 len,
+ bool uptodate);
void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode,
struct page *page, u64 file_offset,
u64 num_bytes, bool uptodate);
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index 8ea9cea9bfeb4d..c0f308ef6f7699 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -661,6 +661,35 @@ DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_mark_finished,
TP_ARGS(inode, ordered)
);
+TRACE_EVENT(btrfs_finish_ordered_extent,
+
+ TP_PROTO(const struct btrfs_inode *inode, u64 start, u64 len,
+ int uptodate),
+
+ TP_ARGS(inode, start, len, uptodate),
+
+ TP_STRUCT__entry_btrfs(
+ __field( u64, ino )
+ __field( u64, start )
+ __field( u64, len )
+ __field( int, uptodate )
+ __field( u64, root_objectid )
+ ),
+
+ TP_fast_assign_btrfs(inode->root->fs_info,
+ __entry->ino = btrfs_ino(inode);
+ __entry->start = start;
+ __entry->len = len;
+ __entry->uptodate = uptodate;
+ __entry->root_objectid = inode->root->root_key.objectid;
+ ),
+
+ TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu uptodate=%d",
+ show_root_type(__entry->root_objectid),
+ __entry->ino, __entry->start,
+ __entry->len, __entry->uptodate)
+);
+
DECLARE_EVENT_CLASS(btrfs__writepage,
TP_PROTO(const struct page *page, const struct inode *inode,
--
2.39.2
next prev parent reply other threads:[~2023-05-31 7:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 7:53 add an ordered_extent pointer to struct btrfs_bio v2 Christoph Hellwig
2023-05-31 7:53 ` [PATCH 01/17] btrfs: fix file_offset for REQ_BTRFS_ONE_ORDERED bios that get split Christoph Hellwig
2023-05-31 7:53 ` [PATCH 02/17] btrfs: limit write bios to a single ordered extent Christoph Hellwig
2023-05-31 7:53 ` [PATCH 03/17] btrfs: merge the two calls to btrfs_add_ordered_extent in run_delalloc_nocow Christoph Hellwig
2023-06-01 12:17 ` Johannes Thumshirn
2023-05-31 7:53 ` [PATCH 04/17] btrfs: pass an ordered_extent to btrfs_reloc_clone_csums Christoph Hellwig
2023-05-31 7:53 ` [PATCH 05/17] btrfs: pass an ordered_extent to btrfs_submit_compressed_write Christoph Hellwig
2023-05-31 7:53 ` [PATCH 06/17] btrfs: remove btrfs_add_ordered_extent Christoph Hellwig
2023-05-31 7:54 ` [PATCH 07/17] btrfs: add a is_data_bbio helper Christoph Hellwig
2023-06-01 11:50 ` Johannes Thumshirn
2023-05-31 7:54 ` [PATCH 08/17] btrfs: open code btrfs_bio_end_io in btrfs_dio_submit_io Christoph Hellwig
2023-05-31 7:54 ` [PATCH 09/17] btrfs: add an ordered_extent pointer to struct btrfs_bio Christoph Hellwig
2023-05-31 7:54 ` [PATCH 10/17] btrfs: use bbio->ordered in btrfs_csum_one_bio Christoph Hellwig
2023-05-31 7:54 ` [PATCH 11/17] btrfs: factor out a can_finish_ordered_extent helper Christoph Hellwig
2023-05-31 7:54 ` [PATCH 12/17] btrfs: factor out a btrfs_queue_ordered_fn helper Christoph Hellwig
2023-05-31 7:54 ` Christoph Hellwig [this message]
2023-06-01 11:50 ` [PATCH 13/17] btrfs: add a btrfs_finish_ordered_extent helper Johannes Thumshirn
2023-05-31 7:54 ` [PATCH 14/17] btrfs: open code end_extent_writepage in end_bio_extent_writepage Christoph Hellwig
2023-05-31 7:54 ` [PATCH 15/17] btrfs: use btrfs_finish_ordered_extent to complete compressed writes Christoph Hellwig
2023-05-31 7:54 ` [PATCH 16/17] btrfs: use btrfs_finish_ordered_extent to complete direct writes Christoph Hellwig
2023-05-31 7:54 ` [PATCH 17/17] btrfs: use btrfs_finish_ordered_extent to complete buffered writes Christoph Hellwig
2023-05-31 16:33 ` add an ordered_extent pointer to struct btrfs_bio v2 Josef Bacik
2023-06-12 13:57 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230531075410.480499-14-hch@lst.de \
--to=hch@lst.de \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox