Skip to content

Commit

Permalink
afs: Add stats for data transfer operations
Browse files Browse the repository at this point in the history
Add statistics to /proc/fs/afs/stats for data transfer RPC operations.  New
lines are added that look like:

	file-rd : n=55794 nb=10252282150
	file-wr : n=9789 nb=3247763645

where n= indicates the number of ops completed and nb= indicates the number
of bytes successfully transferred.  file-rd is the counts for read/fetch
operations and file-wr the counts for write/store operations.

Note that directory and symlink downloading are included in the file-rd
stats at the moment.

Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
dhowells committed Apr 9, 2018
1 parent 5f702c8 commit 76a5cb6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/afs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *de
ret = afs_end_vnode_operation(&fc);
}

if (ret == 0) {
afs_stat_v(vnode, n_fetches);
atomic_long_add(desc->actual_len,
&afs_v2net(vnode)->n_fetch_bytes);
}

_leave(" = %d", ret);
return ret;
}
Expand Down
4 changes: 4 additions & 0 deletions fs/afs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ struct afs_net {
atomic_t n_read_dir; /* Number of directory pages read */
atomic_t n_dir_cr; /* Number of directory entry creation edits */
atomic_t n_dir_rm; /* Number of directory entry removal edits */
atomic_t n_stores; /* Number of store ops */
atomic_long_t n_store_bytes; /* Number of bytes stored */
atomic_long_t n_fetch_bytes; /* Number of bytes fetched */
atomic_t n_fetches; /* Number of data fetch ops */
};

extern const char afs_init_sysname[];
Expand Down
7 changes: 7 additions & 0 deletions fs/afs/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,13 @@ static int afs_proc_stats_show(struct seq_file *m, void *v)
seq_printf(m, "dir-edit: cr=%u rm=%u\n",
atomic_read(&net->n_dir_cr),
atomic_read(&net->n_dir_rm));

seq_printf(m, "file-rd : n=%u nb=%lu\n",
atomic_read(&net->n_fetches),
atomic_long_read(&net->n_fetch_bytes));
seq_printf(m, "file-wr : n=%u nb=%lu\n",
atomic_read(&net->n_stores),
atomic_long_read(&net->n_store_bytes));
return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions fs/afs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ static int afs_store_data(struct address_space *mapping,
}

switch (ret) {
case 0:
afs_stat_v(vnode, n_stores);
atomic_long_add((last * PAGE_SIZE + to) -
(first * PAGE_SIZE + offset),
&afs_v2net(vnode)->n_store_bytes);
break;
case -EACCES:
case -EPERM:
case -ENOKEY:
Expand Down

0 comments on commit 76a5cb6

Please sign in to comment.