Commit 2de5599f authored by David Howells's avatar David Howells
Browse files

afs: Wrap most op->error accesses with inline funcs



Wrap most op->error accesses with inline funcs which will make it easier
for a subsequent patch to replace op->error with something else.  Two
functions are added to this end:

 (1) afs_op_error() - Get the error code.

 (2) afs_op_set_error() - Set the error code.

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
parent 075171fd
Loading
Loading
Loading
Loading
+19 −19
Original line number Diff line number Diff line
@@ -878,14 +878,14 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
	 * lookups contained therein are stored in the reply without aborting
	 * the whole operation.
	 */
	op->error = -ENOTSUPP;
	afs_op_set_error(op, -ENOTSUPP);
	if (!cookie->one_only) {
		op->ops = &afs_inline_bulk_status_operation;
		afs_begin_vnode_operation(op);
		afs_wait_for_operation(op);
	}

	if (op->error == -ENOTSUPP) {
	if (afs_op_error(op) == -ENOTSUPP) {
		/* We could try FS.BulkStatus next, but this aborts the entire
		 * op if any of the lookups fails - so, for the moment, revert
		 * to FS.FetchStatus for op->file[1].
@@ -895,10 +895,10 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
		afs_begin_vnode_operation(op);
		afs_wait_for_operation(op);
	}
	inode = ERR_PTR(op->error);
	inode = ERR_PTR(afs_op_error(op));

out_op:
	if (op->error == 0) {
	if (!afs_op_error(op)) {
		inode = &op->file[1].vnode->netfs.inode;
		op->file[1].vnode = NULL;
	}
@@ -1273,7 +1273,7 @@ static void afs_vnode_new_inode(struct afs_operation *op)

	_enter("");

	ASSERTCMP(op->error, ==, 0);
	ASSERTCMP(afs_op_error(op), ==, 0);

	inode = afs_iget(op, vp);
	if (IS_ERR(inode)) {
@@ -1286,7 +1286,7 @@ static void afs_vnode_new_inode(struct afs_operation *op)

	vnode = AFS_FS_I(inode);
	set_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags);
	if (!op->error)
	if (!afs_op_error(op))
		afs_cache_permit(vnode, op->key, vnode->cb_break, &vp->scb);
	d_instantiate(op->dentry, inode);
}
@@ -1320,7 +1320,7 @@ static void afs_create_put(struct afs_operation *op)
{
	_enter("op=%08x", op->debug_id);

	if (op->error)
	if (afs_op_error(op))
		d_drop(op->dentry);
}

@@ -1480,7 +1480,7 @@ static void afs_dir_remove_link(struct afs_operation *op)
	struct dentry *dentry = op->dentry;
	int ret;

	if (op->error != 0 ||
	if (afs_op_error(op) ||
	    (op->file[1].scb.have_status && op->file[1].scb.have_error))
		return;
	if (d_really_is_positive(dentry))
@@ -1504,10 +1504,10 @@ static void afs_dir_remove_link(struct afs_operation *op)

		ret = afs_validate(vnode, op->key);
		if (ret != -ESTALE)
			op->error = ret;
			afs_op_set_error(op, ret);
	}

	_debug("nlink %d [val %d]", vnode->netfs.inode.i_nlink, op->error);
	_debug("nlink %d [val %d]", vnode->netfs.inode.i_nlink, afs_op_error(op));
}

static void afs_unlink_success(struct afs_operation *op)
@@ -1538,7 +1538,7 @@ static void afs_unlink_edit_dir(struct afs_operation *op)
static void afs_unlink_put(struct afs_operation *op)
{
	_enter("op=%08x", op->debug_id);
	if (op->unlink.need_rehash && op->error < 0 && op->error != -ENOENT)
	if (op->unlink.need_rehash && afs_op_error(op) < 0 && afs_op_error(op) != -ENOENT)
		d_rehash(op->dentry);
}

@@ -1579,7 +1579,7 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
	/* Try to make sure we have a callback promise on the victim. */
	ret = afs_validate(vnode, op->key);
	if (ret < 0) {
		op->error = ret;
		afs_op_set_error(op, ret);
		goto error;
	}

@@ -1588,7 +1588,7 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
		spin_unlock(&dentry->d_lock);
		/* Start asynchronous writeout of the inode */
		write_inode_now(d_inode(dentry), 0);
		op->error = afs_sillyrename(dvnode, vnode, dentry, op->key);
		afs_op_set_error(op, afs_sillyrename(dvnode, vnode, dentry, op->key));
		goto error;
	}
	if (!d_unhashed(dentry)) {
@@ -1609,7 +1609,7 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
	/* If there was a conflict with a third party, check the status of the
	 * unlinked vnode.
	 */
	if (op->error == 0 && (op->flags & AFS_OPERATION_DIR_CONFLICT)) {
	if (afs_op_error(op) == 0 && (op->flags & AFS_OPERATION_DIR_CONFLICT)) {
		op->file[1].update_ctime = false;
		op->fetch_status.which = 1;
		op->ops = &afs_fetch_status_operation;
@@ -1691,7 +1691,7 @@ static void afs_link_success(struct afs_operation *op)
static void afs_link_put(struct afs_operation *op)
{
	_enter("op=%08x", op->debug_id);
	if (op->error)
	if (afs_op_error(op))
		d_drop(op->dentry);
}

@@ -1889,7 +1889,7 @@ static void afs_rename_put(struct afs_operation *op)
	if (op->rename.rehash)
		d_rehash(op->rename.rehash);
	dput(op->rename.tmp);
	if (op->error)
	if (afs_op_error(op))
		d_rehash(op->dentry);
}

@@ -1934,7 +1934,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
		return PTR_ERR(op);

	ret = afs_validate(vnode, op->key);
	op->error = ret;
	afs_op_set_error(op, ret);
	if (ret < 0)
		goto error;

@@ -1971,7 +1971,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
			op->rename.tmp = d_alloc(new_dentry->d_parent,
						 &new_dentry->d_name);
			if (!op->rename.tmp) {
				op->error = -ENOMEM;
				afs_op_nomem(op);
				goto error;
			}

@@ -1979,7 +1979,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
					      AFS_FS_I(d_inode(new_dentry)),
					      new_dentry, op->key);
			if (ret) {
				op->error = ret;
				afs_op_set_error(op, ret);
				goto error;
			}

+2 −2
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ static void afs_fetch_data_notify(struct afs_operation *op)
{
	struct afs_read *req = op->fetch.req;
	struct netfs_io_subrequest *subreq = req->subreq;
	int error = op->error;
	int error = afs_op_error(op);

	if (error == -ECONNABORTED)
		error = afs_abort_to_error(op->ac.abort_code);
@@ -271,7 +271,7 @@ static void afs_fetch_data_success(struct afs_operation *op)

static void afs_fetch_data_put(struct afs_operation *op)
{
	op->fetch.req->error = op->error;
	op->fetch.req->error = afs_op_error(op);
	afs_put_read(op->fetch.req);
}

+12 −9
Original line number Diff line number Diff line
@@ -40,8 +40,8 @@ struct afs_operation *afs_alloc_operation(struct key *key, struct afs_volume *vo
	op->net		= volume->cell->net;
	op->cb_v_break	= volume->cb_v_break;
	op->debug_id	= atomic_inc_return(&afs_operation_debug_counter);
	op->error	= -EDESTADDRREQ;
	op->nr_iterations = -1;
	afs_op_set_error(op, -EDESTADDRREQ);

	_leave(" = [op=%08x]", op->debug_id);
	return op;
@@ -71,7 +71,7 @@ static bool afs_get_io_locks(struct afs_operation *op)
		swap(vnode, vnode2);

	if (mutex_lock_interruptible(&vnode->io_lock) < 0) {
		op->error = -ERESTARTSYS;
		afs_op_set_error(op, -ERESTARTSYS);
		op->flags |= AFS_OPERATION_STOP;
		_leave(" = f [I 0]");
		return false;
@@ -80,7 +80,7 @@ static bool afs_get_io_locks(struct afs_operation *op)

	if (vnode2) {
		if (mutex_lock_interruptible_nested(&vnode2->io_lock, 1) < 0) {
			op->error = -ERESTARTSYS;
			afs_op_set_error(op, -ERESTARTSYS);
			op->flags |= AFS_OPERATION_STOP;
			mutex_unlock(&vnode->io_lock);
			op->flags &= ~AFS_OPERATION_LOCK_0;
@@ -159,11 +159,14 @@ static void afs_end_vnode_operation(struct afs_operation *op)
{
	_enter("");

	if (op->error == -EDESTADDRREQ ||
	    op->error == -EADDRNOTAVAIL ||
	    op->error == -ENETUNREACH ||
	    op->error == -EHOSTUNREACH)
	switch (afs_op_error(op)) {
	case -EDESTADDRREQ:
	case -EADDRNOTAVAIL:
	case -ENETUNREACH:
	case -EHOSTUNREACH:
		afs_dump_edestaddrreq(op);
		break;
	}

	afs_drop_io_locks(op);

@@ -209,7 +212,7 @@ void afs_wait_for_operation(struct afs_operation *op)

	afs_end_vnode_operation(op);

	if (op->error == 0 && op->ops->edit_dir) {
	if (!afs_op_error(op) && op->ops->edit_dir) {
		_debug("edit_dir");
		op->ops->edit_dir(op);
	}
@@ -221,7 +224,7 @@ void afs_wait_for_operation(struct afs_operation *op)
 */
int afs_put_operation(struct afs_operation *op)
{
	int i, ret = op->error;
	int i, ret = afs_op_error(op);

	_enter("op=%08x,%d", op->debug_id, ret);

+1 −1
Original line number Diff line number Diff line
@@ -1899,7 +1899,7 @@ void afs_fs_inline_bulk_status(struct afs_operation *op)
	int i;

	if (test_bit(AFS_SERVER_FL_NO_IBULK, &op->server->flags)) {
		op->error = -ENOTSUPP;
		afs_op_set_error(op, -ENOTSUPP);
		return;
	}

+1 −1
Original line number Diff line number Diff line
@@ -331,7 +331,7 @@ static void afs_fetch_status_success(struct afs_operation *op)

	if (vnode->netfs.inode.i_state & I_NEW) {
		ret = afs_inode_init_from_status(op, vp, vnode);
		op->error = ret;
		afs_op_set_error(op, ret);
		if (ret == 0)
			afs_cache_permit(vnode, op->key, vp->cb_break_before, &vp->scb);
	} else {
Loading