Skip to content

Commit f51375c

Browse files
committed
afs: Add a couple of tracepoints to log I/O errors
Add a couple of tracepoints to log the production of I/O errors within the AFS filesystem. Signed-off-by: David Howells <[email protected]>
1 parent 4ac15ea commit f51375c

File tree

8 files changed

+114
-16
lines changed

8 files changed

+114
-16
lines changed

fs/afs/cmservice.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
260260
}
261261

262262
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
263-
return -EIO;
263+
return afs_io_error(call, afs_io_error_cm_reply);
264264

265265
/* we'll need the file server record as that tells us which set of
266266
* vnodes to operate upon */
@@ -368,7 +368,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
368368
}
369369

370370
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
371-
return -EIO;
371+
return afs_io_error(call, afs_io_error_cm_reply);
372372

373373
/* we'll need the file server record as that tells us which set of
374374
* vnodes to operate upon */
@@ -409,7 +409,7 @@ static int afs_deliver_cb_probe(struct afs_call *call)
409409
return ret;
410410

411411
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
412-
return -EIO;
412+
return afs_io_error(call, afs_io_error_cm_reply);
413413

414414
return afs_queue_call_work(call);
415415
}
@@ -490,7 +490,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
490490
}
491491

492492
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
493-
return -EIO;
493+
return afs_io_error(call, afs_io_error_cm_reply);
494494

495495
return afs_queue_call_work(call);
496496
}
@@ -573,7 +573,7 @@ static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call)
573573
return ret;
574574

575575
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
576-
return -EIO;
576+
return afs_io_error(call, afs_io_error_cm_reply);
577577

578578
return afs_queue_call_work(call);
579579
}

fs/afs/dir.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static bool afs_dir_check_page(struct afs_vnode *dvnode, struct page *page,
138138
ntohs(dbuf->blocks[tmp].hdr.magic));
139139
trace_afs_dir_check_failed(dvnode, off, i_size);
140140
kunmap(page);
141+
trace_afs_file_error(dvnode, -EIO, afs_file_error_dir_bad_magic);
141142
goto error;
142143
}
143144

@@ -190,9 +191,11 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
190191
retry:
191192
i_size = i_size_read(&dvnode->vfs_inode);
192193
if (i_size < 2048)
193-
return ERR_PTR(-EIO);
194-
if (i_size > 2048 * 1024)
194+
return ERR_PTR(afs_bad(dvnode, afs_file_error_dir_small));
195+
if (i_size > 2048 * 1024) {
196+
trace_afs_file_error(dvnode, -EFBIG, afs_file_error_dir_big);
195197
return ERR_PTR(-EFBIG);
198+
}
196199

197200
_enter("%llu", i_size);
198201

@@ -315,7 +318,8 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
315318
/*
316319
* deal with one block in an AFS directory
317320
*/
318-
static int afs_dir_iterate_block(struct dir_context *ctx,
321+
static int afs_dir_iterate_block(struct afs_vnode *dvnode,
322+
struct dir_context *ctx,
319323
union afs_xdr_dir_block *block,
320324
unsigned blkoff)
321325
{
@@ -365,15 +369,15 @@ static int afs_dir_iterate_block(struct dir_context *ctx,
365369
" (len %u/%zu)",
366370
blkoff / sizeof(union afs_xdr_dir_block),
367371
offset, next, tmp, nlen);
368-
return -EIO;
372+
return afs_bad(dvnode, afs_file_error_dir_over_end);
369373
}
370374
if (!(block->hdr.bitmap[next / 8] &
371375
(1 << (next % 8)))) {
372376
_debug("ENT[%zu.%u]:"
373377
" %u unmarked extension (len %u/%zu)",
374378
blkoff / sizeof(union afs_xdr_dir_block),
375379
offset, next, tmp, nlen);
376-
return -EIO;
380+
return afs_bad(dvnode, afs_file_error_dir_unmarked_ext);
377381
}
378382

379383
_debug("ENT[%zu.%u]: ext %u/%zu",
@@ -442,7 +446,7 @@ static int afs_dir_iterate(struct inode *dir, struct dir_context *ctx,
442446
*/
443447
page = req->pages[blkoff / PAGE_SIZE];
444448
if (!page) {
445-
ret = -EIO;
449+
ret = afs_bad(dvnode, afs_file_error_dir_missing_page);
446450
break;
447451
}
448452
mark_page_accessed(page);
@@ -455,7 +459,7 @@ static int afs_dir_iterate(struct inode *dir, struct dir_context *ctx,
455459
do {
456460
dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) /
457461
sizeof(union afs_xdr_dir_block)];
458-
ret = afs_dir_iterate_block(ctx, dblock, blkoff);
462+
ret = afs_dir_iterate_block(dvnode, ctx, dblock, blkoff);
459463
if (ret != 1) {
460464
kunmap(page);
461465
goto out;

fs/afs/internal.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,17 @@ static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc,
12571257
}
12581258
}
12591259

1260+
static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
1261+
{
1262+
trace_afs_io_error(call->debug_id, -EIO, where);
1263+
return -EIO;
1264+
}
1265+
1266+
static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where)
1267+
{
1268+
trace_afs_file_error(vnode, -EIO, where);
1269+
return -EIO;
1270+
}
12601271

12611272
/*****************************************************************************/
12621273
/*

fs/afs/mntpt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
130130
goto error_no_page;
131131
}
132132

133-
ret = -EIO;
134-
if (PageError(page))
133+
if (PageError(page)) {
134+
ret = afs_bad(AFS_FS_I(d_inode(mntpt)), afs_file_error_mntpt);
135135
goto error;
136+
}
136137

137138
buf = kmap_atomic(page);
138139
memcpy(devname, buf, size);

fs/afs/rxrpc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ int afs_extract_data(struct afs_call *call, bool want_more)
915915
break;
916916
case AFS_CALL_COMPLETE:
917917
kdebug("prem complete %d", call->error);
918-
return -EIO;
918+
return afs_io_error(call, afs_io_error_extract);
919919
default:
920920
break;
921921
}

fs/afs/server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static bool afs_do_probe_fileserver(struct afs_fs_cursor *fc)
542542
case -ETIME:
543543
break;
544544
default:
545-
fc->ac.error = -EIO;
545+
fc->ac.error = afs_io_error(NULL, afs_io_error_fs_probe_fail);
546546
goto error;
547547
}
548548
}

fs/afs/write.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ static int afs_write_back_from_locked_page(struct address_space *mapping,
533533
case -ENOENT:
534534
case -ENOMEDIUM:
535535
case -ENXIO:
536+
trace_afs_file_error(vnode, ret, afs_file_error_writeback_fail);
536537
afs_kill_pages(mapping, first, last);
537538
mapping_set_error(mapping, ret);
538539
break;

include/trace/events/afs.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ enum afs_eproto_cause {
103103
afs_eproto_yvl_vlendpt_type,
104104
};
105105

106+
enum afs_io_error {
107+
afs_io_error_cm_reply,
108+
afs_io_error_extract,
109+
afs_io_error_fs_probe_fail,
110+
afs_io_error_vl_lookup_fail,
111+
};
112+
113+
enum afs_file_error {
114+
afs_file_error_dir_bad_magic,
115+
afs_file_error_dir_big,
116+
afs_file_error_dir_missing_page,
117+
afs_file_error_dir_over_end,
118+
afs_file_error_dir_small,
119+
afs_file_error_dir_unmarked_ext,
120+
afs_file_error_mntpt,
121+
afs_file_error_writeback_fail,
122+
};
123+
106124
#endif /* end __AFS_DECLARE_TRACE_ENUMS_ONCE_ONLY */
107125

108126
/*
@@ -183,6 +201,21 @@ enum afs_eproto_cause {
183201
EM(afs_eproto_yvl_vlendpt6_len, "YVL.VlEnd6Len") \
184202
E_(afs_eproto_yvl_vlendpt_type, "YVL.VlEndType")
185203

204+
#define afs_io_errors \
205+
EM(afs_io_error_cm_reply, "CM_REPLY") \
206+
EM(afs_io_error_extract, "EXTRACT") \
207+
EM(afs_io_error_fs_probe_fail, "FS_PROBE_FAIL") \
208+
E_(afs_io_error_vl_lookup_fail, "VL_LOOKUP_FAIL")
209+
210+
#define afs_file_errors \
211+
EM(afs_file_error_dir_bad_magic, "DIR_BAD_MAGIC") \
212+
EM(afs_file_error_dir_big, "DIR_BIG") \
213+
EM(afs_file_error_dir_missing_page, "DIR_MISSING_PAGE") \
214+
EM(afs_file_error_dir_over_end, "DIR_ENT_OVER_END") \
215+
EM(afs_file_error_dir_small, "DIR_SMALL") \
216+
EM(afs_file_error_dir_unmarked_ext, "DIR_UNMARKED_EXT") \
217+
EM(afs_file_error_mntpt, "MNTPT_READ_FAILED") \
218+
E_(afs_file_error_writeback_fail, "WRITEBACK_FAILED")
186219

187220
/*
188221
* Export enum symbols via userspace.
@@ -197,6 +230,9 @@ afs_fs_operations;
197230
afs_vl_operations;
198231
afs_edit_dir_ops;
199232
afs_edit_dir_reasons;
233+
afs_eproto_causes;
234+
afs_io_errors;
235+
afs_file_errors;
200236

201237
/*
202238
* Now redefine the EM() and E_() macros to map the enums to the strings that
@@ -613,6 +649,51 @@ TRACE_EVENT(afs_protocol_error,
613649
__print_symbolic(__entry->cause, afs_eproto_causes))
614650
);
615651

652+
TRACE_EVENT(afs_io_error,
653+
TP_PROTO(unsigned int call, int error, enum afs_io_error where),
654+
655+
TP_ARGS(call, error, where),
656+
657+
TP_STRUCT__entry(
658+
__field(unsigned int, call )
659+
__field(int, error )
660+
__field(enum afs_io_error, where )
661+
),
662+
663+
TP_fast_assign(
664+
__entry->call = call;
665+
__entry->error = error;
666+
__entry->where = where;
667+
),
668+
669+
TP_printk("c=%08x r=%d %s",
670+
__entry->call, __entry->error,
671+
__print_symbolic(__entry->where, afs_io_errors))
672+
);
673+
674+
TRACE_EVENT(afs_file_error,
675+
TP_PROTO(struct afs_vnode *vnode, int error, enum afs_file_error where),
676+
677+
TP_ARGS(vnode, error, where),
678+
679+
TP_STRUCT__entry(
680+
__field_struct(struct afs_fid, fid )
681+
__field(int, error )
682+
__field(enum afs_file_error, where )
683+
),
684+
685+
TP_fast_assign(
686+
__entry->fid = vnode->fid;
687+
__entry->error = error;
688+
__entry->where = where;
689+
),
690+
691+
TP_printk("%x:%x:%x r=%d %s",
692+
__entry->fid.vid, __entry->fid.vnode, __entry->fid.unique,
693+
__entry->error,
694+
__print_symbolic(__entry->where, afs_file_errors))
695+
);
696+
616697
TRACE_EVENT(afs_cm_no_server,
617698
TP_PROTO(struct afs_call *call, struct sockaddr_rxrpc *srx),
618699

0 commit comments

Comments
 (0)