Skip to content

Commit af887e4

Browse files
author
Trond Myklebust
committed
NFS: Improve write error tracing
Don't leak request pointers, but use the "device:inode" labelling that is used by all the other trace points. Furthermore, replace use of page indexes with an offset, again in order to align behaviour with other NFS trace points. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 3c59366 commit af887e4

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

fs/nfs/nfstrace.h

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,44 +1447,50 @@ TRACE_EVENT(nfs_writeback_done,
14471447

14481448
DECLARE_EVENT_CLASS(nfs_page_error_class,
14491449
TP_PROTO(
1450+
const struct inode *inode,
14501451
const struct nfs_page *req,
14511452
int error
14521453
),
14531454

1454-
TP_ARGS(req, error),
1455+
TP_ARGS(inode, req, error),
14551456

14561457
TP_STRUCT__entry(
1457-
__field(const void *, req)
1458-
__field(pgoff_t, index)
1459-
__field(unsigned int, offset)
1460-
__field(unsigned int, pgbase)
1461-
__field(unsigned int, bytes)
1458+
__field(dev_t, dev)
1459+
__field(u32, fhandle)
1460+
__field(u64, fileid)
1461+
__field(loff_t, offset)
1462+
__field(unsigned int, count)
14621463
__field(int, error)
14631464
),
14641465

14651466
TP_fast_assign(
1466-
__entry->req = req;
1467-
__entry->index = req->wb_index;
1468-
__entry->offset = req->wb_offset;
1469-
__entry->pgbase = req->wb_pgbase;
1470-
__entry->bytes = req->wb_bytes;
1467+
const struct nfs_inode *nfsi = NFS_I(inode);
1468+
__entry->dev = inode->i_sb->s_dev;
1469+
__entry->fileid = nfsi->fileid;
1470+
__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
1471+
__entry->offset = req_offset(req);
1472+
__entry->count = req->wb_bytes;
14711473
__entry->error = error;
14721474
),
14731475

14741476
TP_printk(
1475-
"req=%p index=%lu offset=%u pgbase=%u bytes=%u error=%d",
1476-
__entry->req, __entry->index, __entry->offset,
1477-
__entry->pgbase, __entry->bytes, __entry->error
1477+
"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
1478+
"offset=%lld count=%u", __entry->error,
1479+
MAJOR(__entry->dev), MINOR(__entry->dev),
1480+
(unsigned long long)__entry->fileid,
1481+
__entry->fhandle, __entry->offset,
1482+
__entry->count
14781483
)
14791484
);
14801485

14811486
#define DEFINE_NFS_PAGEERR_EVENT(name) \
14821487
DEFINE_EVENT(nfs_page_error_class, name, \
14831488
TP_PROTO( \
1489+
const struct inode *inode, \
14841490
const struct nfs_page *req, \
14851491
int error \
14861492
), \
1487-
TP_ARGS(req, error))
1493+
TP_ARGS(inode, req, error))
14881494

14891495
DEFINE_NFS_PAGEERR_EVENT(nfs_write_error);
14901496
DEFINE_NFS_PAGEERR_EVENT(nfs_comp_error);

fs/nfs/write.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,8 @@ nfs_lock_and_join_requests(struct page *page)
592592

593593
static void nfs_write_error(struct nfs_page *req, int error)
594594
{
595-
trace_nfs_write_error(req, error);
595+
trace_nfs_write_error(page_file_mapping(req->wb_page)->host, req,
596+
error);
596597
nfs_mapping_set_error(req->wb_page, error);
597598
nfs_inode_remove_request(req);
598599
nfs_end_page_writeback(req);
@@ -1000,7 +1001,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr)
10001001
nfs_list_remove_request(req);
10011002
if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) &&
10021003
(hdr->good_bytes < bytes)) {
1003-
trace_nfs_comp_error(req, hdr->error);
1004+
trace_nfs_comp_error(hdr->inode, req, hdr->error);
10041005
nfs_mapping_set_error(req->wb_page, hdr->error);
10051006
goto remove_req;
10061007
}
@@ -1882,7 +1883,8 @@ static void nfs_commit_release_pages(struct nfs_commit_data *data)
18821883
(long long)req_offset(req));
18831884
if (status < 0) {
18841885
if (req->wb_page) {
1885-
trace_nfs_commit_error(req, status);
1886+
trace_nfs_commit_error(data->inode, req,
1887+
status);
18861888
nfs_mapping_set_error(req->wb_page, status);
18871889
nfs_inode_remove_request(req);
18881890
}

include/linux/nfs_page.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ nfs_list_entry(struct list_head *head)
202202
return list_entry(head, struct nfs_page, wb_list);
203203
}
204204

205-
static inline
206-
loff_t req_offset(struct nfs_page *req)
205+
static inline loff_t req_offset(const struct nfs_page *req)
207206
{
208207
return (((loff_t)req->wb_index) << PAGE_SHIFT) + req->wb_offset;
209208
}

0 commit comments

Comments
 (0)