Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+27 -20
+21 -15
fs/nfs/nfstrace.h
··· 1447 1447 1448 1448 DECLARE_EVENT_CLASS(nfs_page_error_class, 1449 1449 TP_PROTO( 1450 + const struct inode *inode, 1450 1451 const struct nfs_page *req, 1451 1452 int error 1452 1453 ), 1453 1454 1454 - TP_ARGS(req, error), 1455 + TP_ARGS(inode, req, error), 1455 1456 1456 1457 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) 1462 1463 __field(int, error) 1463 1464 ), 1464 1465 1465 1466 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; 1471 1473 __entry->error = error; 1472 1474 ), 1473 1475 1474 1476 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 1478 1483 ) 1479 1484 ); 1480 1485 1481 1486 #define DEFINE_NFS_PAGEERR_EVENT(name) \ 1482 1487 DEFINE_EVENT(nfs_page_error_class, name, \ 1483 1488 TP_PROTO( \ 1489 + const struct inode *inode, \ 1484 1490 const struct nfs_page *req, \ 1485 1491 int error \ 1486 1492 ), \ 1487 - TP_ARGS(req, error)) 1493 + TP_ARGS(inode, req, error)) 1488 1494 1489 1495 DEFINE_NFS_PAGEERR_EVENT(nfs_write_error); 1490 1496 DEFINE_NFS_PAGEERR_EVENT(nfs_comp_error);
+5 -3
fs/nfs/write.c
··· 592 592 593 593 static void nfs_write_error(struct nfs_page *req, int error) 594 594 { 595 - trace_nfs_write_error(req, error); 595 + trace_nfs_write_error(page_file_mapping(req->wb_page)->host, req, 596 + error); 596 597 nfs_mapping_set_error(req->wb_page, error); 597 598 nfs_inode_remove_request(req); 598 599 nfs_end_page_writeback(req); ··· 1001 1000 nfs_list_remove_request(req); 1002 1001 if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) && 1003 1002 (hdr->good_bytes < bytes)) { 1004 - trace_nfs_comp_error(req, hdr->error); 1003 + trace_nfs_comp_error(hdr->inode, req, hdr->error); 1005 1004 nfs_mapping_set_error(req->wb_page, hdr->error); 1006 1005 goto remove_req; 1007 1006 } ··· 1883 1882 (long long)req_offset(req)); 1884 1883 if (status < 0) { 1885 1884 if (req->wb_page) { 1886 - trace_nfs_commit_error(req, status); 1885 + trace_nfs_commit_error(data->inode, req, 1886 + status); 1887 1887 nfs_mapping_set_error(req->wb_page, status); 1888 1888 nfs_inode_remove_request(req); 1889 1889 }
+1 -2
include/linux/nfs_page.h
··· 202 202 return list_entry(head, struct nfs_page, wb_list); 203 203 } 204 204 205 - static inline 206 - loff_t req_offset(struct nfs_page *req) 205 + static inline loff_t req_offset(const struct nfs_page *req) 207 206 { 208 207 return (((loff_t)req->wb_index) << PAGE_SHIFT) + req->wb_offset; 209 208 }