Skip to content

Commit bedf149

Browse files
committed
Merge tag 'iomap-6.4-merge-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull iomap updates from Darrick Wong: "The only changes for this cycle are the addition of tracepoints to the iomap directio code so that Ritesh (who is working on porting ext2 to iomap) can observe the io flows more easily. Summary: - Remove an unused symbol - Add tracepoints for the directio code" * tag 'iomap-6.4-merge-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: iomap: Add DIO tracepoints iomap: Remove IOMAP_DIO_NOSYNC unused dio flag fs.h: Add TRACE_IOCB_STRINGS for use in trace points
2 parents b28e631 + 3fd4172 commit bedf149

5 files changed

Lines changed: 100 additions & 8 deletions

File tree

fs/iomap/direct-io.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
130130
if (ret > 0)
131131
ret += dio->done_before;
132132

133+
trace_iomap_dio_complete(iocb, dio->error, ret);
133134
kfree(dio);
134135

135136
return ret;
@@ -493,6 +494,8 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
493494
struct blk_plug plug;
494495
struct iomap_dio *dio;
495496

497+
trace_iomap_dio_rw_begin(iocb, iter, dio_flags, done_before);
498+
496499
if (!iomi.len)
497500
return NULL;
498501

@@ -541,7 +544,7 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
541544
}
542545

543546
/* for data sync or sync, we need sync completion processing */
544-
if (iocb_is_dsync(iocb) && !(dio_flags & IOMAP_DIO_NOSYNC)) {
547+
if (iocb_is_dsync(iocb)) {
545548
dio->flags |= IOMAP_DIO_NEED_SYNC;
546549

547550
/*
@@ -650,8 +653,10 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
650653
*/
651654
dio->wait_for_completion = wait_for_completion;
652655
if (!atomic_dec_and_test(&dio->ref)) {
653-
if (!wait_for_completion)
656+
if (!wait_for_completion) {
657+
trace_iomap_dio_rw_queued(inode, iomi.pos, iomi.len);
654658
return ERR_PTR(-EIOCBQUEUED);
659+
}
655660

656661
for (;;) {
657662
set_current_state(TASK_UNINTERRUPTIBLE);

fs/iomap/trace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2019 Christoph Hellwig
44
*/
55
#include <linux/iomap.h>
6+
#include <linux/uio.h>
67

78
/*
89
* We include this last to have the helpers above available for the trace

fs/iomap/trace.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ DEFINE_RANGE_EVENT(iomap_writepage);
8383
DEFINE_RANGE_EVENT(iomap_release_folio);
8484
DEFINE_RANGE_EVENT(iomap_invalidate_folio);
8585
DEFINE_RANGE_EVENT(iomap_dio_invalidate_fail);
86+
DEFINE_RANGE_EVENT(iomap_dio_rw_queued);
8687

8788
#define IOMAP_TYPE_STRINGS \
8889
{ IOMAP_HOLE, "HOLE" }, \
@@ -107,6 +108,11 @@ DEFINE_RANGE_EVENT(iomap_dio_invalidate_fail);
107108
{ IOMAP_F_BUFFER_HEAD, "BH" }, \
108109
{ IOMAP_F_SIZE_CHANGED, "SIZE_CHANGED" }
109110

111+
#define IOMAP_DIO_STRINGS \
112+
{IOMAP_DIO_FORCE_WAIT, "DIO_FORCE_WAIT" }, \
113+
{IOMAP_DIO_OVERWRITE_ONLY, "DIO_OVERWRITE_ONLY" }, \
114+
{IOMAP_DIO_PARTIAL, "DIO_PARTIAL" }
115+
110116
DECLARE_EVENT_CLASS(iomap_class,
111117
TP_PROTO(struct inode *inode, struct iomap *iomap),
112118
TP_ARGS(inode, iomap),
@@ -183,6 +189,78 @@ TRACE_EVENT(iomap_iter,
183189
(void *)__entry->caller)
184190
);
185191

192+
TRACE_EVENT(iomap_dio_rw_begin,
193+
TP_PROTO(struct kiocb *iocb, struct iov_iter *iter,
194+
unsigned int dio_flags, size_t done_before),
195+
TP_ARGS(iocb, iter, dio_flags, done_before),
196+
TP_STRUCT__entry(
197+
__field(dev_t, dev)
198+
__field(ino_t, ino)
199+
__field(loff_t, isize)
200+
__field(loff_t, pos)
201+
__field(size_t, count)
202+
__field(size_t, done_before)
203+
__field(int, ki_flags)
204+
__field(unsigned int, dio_flags)
205+
__field(bool, aio)
206+
),
207+
TP_fast_assign(
208+
__entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
209+
__entry->ino = file_inode(iocb->ki_filp)->i_ino;
210+
__entry->isize = file_inode(iocb->ki_filp)->i_size;
211+
__entry->pos = iocb->ki_pos;
212+
__entry->count = iov_iter_count(iter);
213+
__entry->done_before = done_before;
214+
__entry->ki_flags = iocb->ki_flags;
215+
__entry->dio_flags = dio_flags;
216+
__entry->aio = !is_sync_kiocb(iocb);
217+
),
218+
TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx length 0x%zx done_before 0x%zx flags %s dio_flags %s aio %d",
219+
MAJOR(__entry->dev), MINOR(__entry->dev),
220+
__entry->ino,
221+
__entry->isize,
222+
__entry->pos,
223+
__entry->count,
224+
__entry->done_before,
225+
__print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS),
226+
__print_flags(__entry->dio_flags, "|", IOMAP_DIO_STRINGS),
227+
__entry->aio)
228+
);
229+
230+
TRACE_EVENT(iomap_dio_complete,
231+
TP_PROTO(struct kiocb *iocb, int error, ssize_t ret),
232+
TP_ARGS(iocb, error, ret),
233+
TP_STRUCT__entry(
234+
__field(dev_t, dev)
235+
__field(ino_t, ino)
236+
__field(loff_t, isize)
237+
__field(loff_t, pos)
238+
__field(int, ki_flags)
239+
__field(bool, aio)
240+
__field(int, error)
241+
__field(ssize_t, ret)
242+
),
243+
TP_fast_assign(
244+
__entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
245+
__entry->ino = file_inode(iocb->ki_filp)->i_ino;
246+
__entry->isize = file_inode(iocb->ki_filp)->i_size;
247+
__entry->pos = iocb->ki_pos;
248+
__entry->ki_flags = iocb->ki_flags;
249+
__entry->aio = !is_sync_kiocb(iocb);
250+
__entry->error = error;
251+
__entry->ret = ret;
252+
),
253+
TP_printk("dev %d:%d ino 0x%lx size 0x%llx offset 0x%llx flags %s aio %d error %d ret %zd",
254+
MAJOR(__entry->dev), MINOR(__entry->dev),
255+
__entry->ino,
256+
__entry->isize,
257+
__entry->pos,
258+
__print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS),
259+
__entry->aio,
260+
__entry->error,
261+
__entry->ret)
262+
);
263+
186264
#endif /* _IOMAP_TRACE_H */
187265

188266
#undef TRACE_INCLUDE_PATH

include/linux/fs.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,20 @@ enum rw_hint {
343343
/* can use bio alloc cache */
344344
#define IOCB_ALLOC_CACHE (1 << 21)
345345

346+
/* for use in trace events */
347+
#define TRACE_IOCB_STRINGS \
348+
{ IOCB_HIPRI, "HIPRI" }, \
349+
{ IOCB_DSYNC, "DSYNC" }, \
350+
{ IOCB_SYNC, "SYNC" }, \
351+
{ IOCB_NOWAIT, "NOWAIT" }, \
352+
{ IOCB_APPEND, "APPEND" }, \
353+
{ IOCB_EVENTFD, "EVENTFD"}, \
354+
{ IOCB_DIRECT, "DIRECT" }, \
355+
{ IOCB_WRITE, "WRITE" }, \
356+
{ IOCB_WAITQ, "WAITQ" }, \
357+
{ IOCB_NOIO, "NOIO" }, \
358+
{ IOCB_ALLOC_CACHE, "ALLOC_CACHE" }
359+
346360
struct kiocb {
347361
struct file *ki_filp;
348362
loff_t ki_pos;

include/linux/iomap.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,6 @@ struct iomap_dio_ops {
377377
*/
378378
#define IOMAP_DIO_PARTIAL (1 << 2)
379379

380-
/*
381-
* The caller will sync the write if needed; do not sync it within
382-
* iomap_dio_rw. Overrides IOMAP_DIO_FORCE_WAIT.
383-
*/
384-
#define IOMAP_DIO_NOSYNC (1 << 3)
385-
386380
ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
387381
const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
388382
unsigned int dio_flags, void *private, size_t done_before);

0 commit comments

Comments
 (0)