[PATCH 09/10] afs: Add a couple of tracepoints to log I/O errors

2018-09-13 Thread David Howells
Add a couple of tracepoints to log the production of I/O errors within the AFS
filesystem.

Signed-off-by: David Howells 
---

 fs/afs/cmservice.c |   10 +++--
 fs/afs/dir.c   |   23 
 fs/afs/internal.h  |   11 ++
 fs/afs/mntpt.c |6 +++
 fs/afs/rxrpc.c |2 +
 fs/afs/server.c|4 +-
 fs/afs/volume.c|2 +
 fs/afs/write.c |1 +
 include/trace/events/afs.h |   81 
 9 files changed, 122 insertions(+), 18 deletions(-)

diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index 4db62ae8dc1a..186f621f8722 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -260,7 +260,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
}
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
/* we'll need the file server record as that tells us which set of
 * vnodes to operate upon */
@@ -368,7 +368,7 @@ static int afs_deliver_cb_init_call_back_state3(struct 
afs_call *call)
}
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
/* we'll need the file server record as that tells us which set of
 * vnodes to operate upon */
@@ -409,7 +409,7 @@ static int afs_deliver_cb_probe(struct afs_call *call)
return ret;
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
return afs_queue_call_work(call);
 }
@@ -490,7 +490,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
}
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
return afs_queue_call_work(call);
 }
@@ -573,7 +573,7 @@ static int afs_deliver_cb_tell_me_about_yourself(struct 
afs_call *call)
return ret;
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
return afs_queue_call_work(call);
 }
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index c36b54b7450b..15f740b910fb 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -172,6 +172,7 @@ static bool afs_dir_check_page(struct afs_vnode *dvnode, 
struct page *page,
   ntohs(dbuf->blocks[tmp].hdr.magic));
trace_afs_dir_check_failed(dvnode, off, i_size);
kunmap(page);
+   trace_afs_file_error(dvnode, -EIO, 
afs_file_error_dir_bad_magic);
goto error;
}
 
@@ -271,12 +272,15 @@ static struct afs_read *afs_read_dir(struct afs_vnode 
*dvnode, struct key *key)
 
 expand:
i_size = i_size_read(&dvnode->vfs_inode);
-   ret = -EIO;
-   if (i_size < 2048)
+   if (i_size < 2048) {
+   ret = afs_bad(dvnode, afs_file_error_dir_small);
goto error;
-   ret = -EFBIG;
-   if (i_size > 2048 * 1024)
+   }
+   if (i_size > 2048 * 1024) {
+   trace_afs_file_error(dvnode, -EFBIG, afs_file_error_dir_big);
+   ret = -EFBIG;
goto error;
+   }
 
nr_pages = (i_size + PAGE_SIZE - 1) / PAGE_SIZE;
 
@@ -381,7 +385,8 @@ static struct afs_read *afs_read_dir(struct afs_vnode 
*dvnode, struct key *key)
 /*
  * deal with one block in an AFS directory
  */
-static int afs_dir_iterate_block(struct dir_context *ctx,
+static int afs_dir_iterate_block(struct afs_vnode *dvnode,
+struct dir_context *ctx,
 union afs_xdr_dir_block *block,
 unsigned blkoff)
 {
@@ -431,7 +436,7 @@ static int afs_dir_iterate_block(struct dir_context *ctx,
   " (len %u/%zu)",
   blkoff / sizeof(union afs_xdr_dir_block),
   offset, next, tmp, nlen);
-   return -EIO;
+   return afs_bad(dvnode, 
afs_file_error_dir_over_end);
}
if (!(block->hdr.bitmap[next / 8] &
  (1 << (next % 8 {
@@ -439,7 +444,7 @@ static int afs_dir_iterate_block(struct dir_context *ctx,
   " %u unmarked extension (len %u/%zu)",
   blkoff / sizeof(union afs_xdr_dir_block),
   offset, next, tmp, nlen);
-   return -EIO;
+   return afs_bad(dvnode, 
afs_file_error_dir

[PATCH 09/10] afs: Add a couple of tracepoints to log I/O errors

2018-08-06 Thread David Howells
Add a couple of tracepoints to log the production of I/O errors within the AFS
filesystem.

Signed-off-by: David Howells 
---

 fs/afs/cmservice.c |   10 +++--
 fs/afs/dir.c   |   23 
 fs/afs/internal.h  |   11 ++
 fs/afs/mntpt.c |2 +
 fs/afs/rxrpc.c |2 +
 fs/afs/server.c|4 +-
 fs/afs/volume.c|2 +
 fs/afs/write.c |1 +
 include/trace/events/afs.h |   81 
 9 files changed, 117 insertions(+), 19 deletions(-)

diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index 4db62ae8dc1a..186f621f8722 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -260,7 +260,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
}
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
/* we'll need the file server record as that tells us which set of
 * vnodes to operate upon */
@@ -368,7 +368,7 @@ static int afs_deliver_cb_init_call_back_state3(struct 
afs_call *call)
}
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
/* we'll need the file server record as that tells us which set of
 * vnodes to operate upon */
@@ -409,7 +409,7 @@ static int afs_deliver_cb_probe(struct afs_call *call)
return ret;
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
return afs_queue_call_work(call);
 }
@@ -490,7 +490,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
}
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
return afs_queue_call_work(call);
 }
@@ -573,7 +573,7 @@ static int afs_deliver_cb_tell_me_about_yourself(struct 
afs_call *call)
return ret;
 
if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
-   return -EIO;
+   return afs_io_error(call, afs_io_error_cm_reply);
 
return afs_queue_call_work(call);
 }
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 1357a10804bb..300514cb33d8 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -173,6 +173,7 @@ static bool afs_dir_check_page(struct afs_vnode *dvnode, 
struct page *page,
   ntohs(dbuf->blocks[tmp].hdr.magic));
trace_afs_dir_check_failed(dvnode, off, i_size);
kunmap(page);
+   trace_afs_file_error(dvnode, -EIO, 
afs_file_error_dir_bad_magic);
goto error;
}
 
@@ -273,12 +274,15 @@ static struct afs_read *afs_read_dir(struct afs_vnode 
*dvnode, struct key *key)
 
 expand:
i_size = i_size_read(&dvnode->vfs_inode);
-   ret = -EIO;
-   if (i_size < 2048)
+   if (i_size < 2048) {
+   ret = afs_bad(dvnode, afs_file_error_dir_small);
goto error;
-   ret = -EFBIG;
-   if (i_size > 2048 * 1024)
+   }
+   if (i_size > 2048 * 1024) {
+   trace_afs_file_error(dvnode, -EFBIG, afs_file_error_dir_big);
+   ret = -EFBIG;
goto error;
+   }
 
nr_pages = (i_size + PAGE_SIZE - 1) / PAGE_SIZE;
 
@@ -383,7 +387,8 @@ static struct afs_read *afs_read_dir(struct afs_vnode 
*dvnode, struct key *key)
 /*
  * deal with one block in an AFS directory
  */
-static int afs_dir_iterate_block(struct dir_context *ctx,
+static int afs_dir_iterate_block(struct afs_vnode *dvnode,
+struct dir_context *ctx,
 union afs_xdr_dir_block *block,
 unsigned blkoff)
 {
@@ -433,7 +438,7 @@ static int afs_dir_iterate_block(struct dir_context *ctx,
   " (len %u/%zu)",
   blkoff / sizeof(union afs_xdr_dir_block),
   offset, next, tmp, nlen);
-   return -EIO;
+   return afs_bad(dvnode, 
afs_file_error_dir_over_end);
}
if (!(block->hdr.bitmap[next / 8] &
  (1 << (next % 8 {
@@ -441,7 +446,7 @@ static int afs_dir_iterate_block(struct dir_context *ctx,
   " %u unmarked extension (len %u/%zu)",
   blkoff / sizeof(union afs_xdr_dir_block),
   offset, next, tmp, nlen);
-   return -EIO;
+   return afs_bad(dvnode, 
afs_file_error_dir_u