Commit 4a55d362 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull AFS updates from David Howells:
 "Minor cleanups and fix:

   - Minor fix to make some debugging statements display information
     from the correct iov_iter.

   - Rename some members and variables to make things more obvious or
     consistent.

   - Provide a helper to wrap increments of the usage count on the
     afs_read struct.

   - Use scnprintf() to print into a stack buffer rather than sprintf().

   - Remove some set but unused variables"

* tag 'afs-next-20191121' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
  afs: Remove set but not used variable 'ret'
  afs: Remove set but not used variables 'before', 'after'
  afs: xattr: use scnprintf
  afs: Introduce an afs_get_read() refcount helper
  afs: Rename desc -> req in afs_fetch_data()
  afs: Switch the naming of call->iter and call->_iter
  afs: Use call->_iter not &call->iter in debugging statements
parents 50b8b3f8 4fe171bb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -342,14 +342,14 @@ static int afs_deliver_cb_callback(struct afs_call *call)
		if (call->count2 != call->count && call->count2 != 0)
			return afs_protocol_error(call, -EBADMSG,
						  afs_eproto_cb_count);
		call->_iter = &call->iter;
		iov_iter_discard(&call->iter, READ, call->count2 * 3 * 4);
		call->iter = &call->def_iter;
		iov_iter_discard(&call->def_iter, READ, call->count2 * 3 * 4);
		call->unmarshall++;

		/* Fall through */
	case 4:
		_debug("extract discard %zu/%u",
		       iov_iter_count(&call->iter), call->count2 * 3 * 4);
		       iov_iter_count(call->iter), call->count2 * 3 * 4);

		ret = afs_extract_data(call, false);
		if (ret < 0)
+2 −10
Original line number Diff line number Diff line
@@ -68,13 +68,11 @@ static int afs_find_contig_bits(union afs_xdr_dir_block *block, unsigned int nr_
static void afs_set_contig_bits(union afs_xdr_dir_block *block,
				int bit, unsigned int nr_slots)
{
	u64 mask, before, after;
	u64 mask;

	mask = (1 << nr_slots) - 1;
	mask <<= bit;

	before = *(u64 *)block->hdr.bitmap;

	block->hdr.bitmap[0] |= (u8)(mask >> 0 * 8);
	block->hdr.bitmap[1] |= (u8)(mask >> 1 * 8);
	block->hdr.bitmap[2] |= (u8)(mask >> 2 * 8);
@@ -83,8 +81,6 @@ static void afs_set_contig_bits(union afs_xdr_dir_block *block,
	block->hdr.bitmap[5] |= (u8)(mask >> 5 * 8);
	block->hdr.bitmap[6] |= (u8)(mask >> 6 * 8);
	block->hdr.bitmap[7] |= (u8)(mask >> 7 * 8);

	after = *(u64 *)block->hdr.bitmap;
}

/*
@@ -93,13 +89,11 @@ static void afs_set_contig_bits(union afs_xdr_dir_block *block,
static void afs_clear_contig_bits(union afs_xdr_dir_block *block,
				  int bit, unsigned int nr_slots)
{
	u64 mask, before, after;
	u64 mask;

	mask = (1 << nr_slots) - 1;
	mask <<= bit;

	before = *(u64 *)block->hdr.bitmap;

	block->hdr.bitmap[0] &= ~(u8)(mask >> 0 * 8);
	block->hdr.bitmap[1] &= ~(u8)(mask >> 1 * 8);
	block->hdr.bitmap[2] &= ~(u8)(mask >> 2 * 8);
@@ -108,8 +102,6 @@ static void afs_clear_contig_bits(union afs_xdr_dir_block *block,
	block->hdr.bitmap[5] &= ~(u8)(mask >> 5 * 8);
	block->hdr.bitmap[6] &= ~(u8)(mask >> 6 * 8);
	block->hdr.bitmap[7] &= ~(u8)(mask >> 7 * 8);

	after = *(u64 *)block->hdr.bitmap;
}

/*
+3 −3
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ static void afs_file_readpage_read_complete(struct page *page,
/*
 * Fetch file data from the volume.
 */
int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *desc)
int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *req)
{
	struct afs_fs_cursor fc;
	struct afs_status_cb *scb;
@@ -246,7 +246,7 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *de

		while (afs_select_fileserver(&fc)) {
			fc.cb_break = afs_calc_vnode_cb_break(vnode);
			afs_fs_fetch_data(&fc, scb, desc);
			afs_fs_fetch_data(&fc, scb, req);
		}

		afs_check_for_remote_deletion(&fc, vnode);
@@ -257,7 +257,7 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *de

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

+7 −9
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
	int ret;

	_enter("{%u,%zu/%llu}",
	       call->unmarshall, iov_iter_count(&call->iter), req->actual_len);
	       call->unmarshall, iov_iter_count(call->iter), req->actual_len);

	switch (call->unmarshall) {
	case 0:
@@ -363,14 +363,14 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
		call->bvec[0].bv_len = size;
		call->bvec[0].bv_offset = req->offset;
		call->bvec[0].bv_page = req->pages[req->index];
		iov_iter_bvec(&call->iter, READ, call->bvec, 1, size);
		iov_iter_bvec(&call->def_iter, READ, call->bvec, 1, size);
		ASSERTCMP(size, <=, PAGE_SIZE);
		/* Fall through */

		/* extract the returned data */
	case 2:
		_debug("extract data %zu/%llu",
		       iov_iter_count(&call->iter), req->remain);
		       iov_iter_count(call->iter), req->remain);

		ret = afs_extract_data(call, true);
		if (ret < 0)
@@ -398,7 +398,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)

	case 3:
		_debug("extract discard %zu/%llu",
		       iov_iter_count(&call->iter), req->actual_len - req->len);
		       iov_iter_count(call->iter), req->actual_len - req->len);

		ret = afs_extract_data(call, true);
		if (ret < 0)
@@ -490,7 +490,7 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc,
	call->key = fc->key;
	call->out_scb = scb;
	call->out_volsync = NULL;
	call->read_request = req;
	call->read_request = afs_get_read(req);

	/* marshall the parameters */
	bp = call->request;
@@ -503,7 +503,6 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc,
	bp[6] = 0;
	bp[7] = htonl(lower_32_bits(req->len));

	refcount_inc(&req->usage);
	afs_use_fs_server(call, fc->cbi);
	trace_afs_make_fs_call(call, &vnode->fid);
	afs_set_fc_call(call, fc);
@@ -540,7 +539,7 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc,
	call->key = fc->key;
	call->out_scb = scb;
	call->out_volsync = NULL;
	call->read_request = req;
	call->read_request = afs_get_read(req);

	/* marshall the parameters */
	bp = call->request;
@@ -551,7 +550,6 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc,
	bp[4] = htonl(lower_32_bits(req->pos));
	bp[5] = htonl(lower_32_bits(req->len));

	refcount_inc(&req->usage);
	afs_use_fs_server(call, fc->cbi);
	trace_afs_make_fs_call(call, &vnode->fid);
	afs_set_fc_call(call, fc);
@@ -1852,7 +1850,7 @@ static int afs_deliver_fs_get_capabilities(struct afs_call *call)
	u32 count;
	int ret;

	_enter("{%u,%zu}", call->unmarshall, iov_iter_count(&call->iter));
	_enter("{%u,%zu}", call->unmarshall, iov_iter_count(call->iter));

	switch (call->unmarshall) {
	case 0:
+11 −5
Original line number Diff line number Diff line
@@ -115,9 +115,9 @@ struct afs_call {
	struct afs_vnode	*lvnode;	/* vnode being locked */
	void			*request;	/* request data (first part) */
	struct address_space	*mapping;	/* Pages being written from */
	struct iov_iter		iter;		/* Buffer iterator */
	struct iov_iter		*_iter;		/* Iterator currently in use */
	union {	/* Convenience for ->iter */
	struct iov_iter		def_iter;	/* Default buffer/data iterator */
	struct iov_iter		*iter;		/* Iterator currently in use */
	union {	/* Convenience for ->def_iter */
		struct kvec	kvec[1];
		struct bio_vec	bvec[1];
	};
@@ -934,6 +934,12 @@ extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *);
extern int afs_page_filler(void *, struct page *);
extern void afs_put_read(struct afs_read *);

static inline struct afs_read *afs_get_read(struct afs_read *req)
{
	refcount_inc(&req->usage);
	return req;
}

/*
 * flock.c
 */
@@ -1136,7 +1142,7 @@ static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t si
{
	call->kvec[0].iov_base = buf;
	call->kvec[0].iov_len = size;
	iov_iter_kvec(&call->iter, READ, call->kvec, 1, size);
	iov_iter_kvec(&call->def_iter, READ, call->kvec, 1, size);
}

static inline void afs_extract_to_tmp(struct afs_call *call)
@@ -1151,7 +1157,7 @@ static inline void afs_extract_to_tmp64(struct afs_call *call)

static inline void afs_extract_discard(struct afs_call *call, size_t size)
{
	iov_iter_discard(&call->iter, READ, size);
	iov_iter_discard(&call->def_iter, READ, size);
}

static inline void afs_extract_to_buf(struct afs_call *call, size_t size)
Loading