public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: piaojun <piaojun@huawei.com>
To: Dominique Martinet <asmadeus@codewreck.org>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"Eric Van Hensbergen" <ericvh@gmail.com>,
	Ron Minnich <rminnich@sandia.gov>,
	"Latchesar Ionkov" <lucho@ionkov.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	<v9fs-developer@lists.sourceforge.net>, <groug@kaod.org>
Subject: [PATCH] fs/9p/xattr.c: catch the error of p9_client_clunk when setting xattr failed
Date: Wed, 25 Jul 2018 11:13:16 +0800	[thread overview]
Message-ID: <5B57EACC.2060900@huawei.com> (raw)

In my testing, v9fs_fid_xattr_set will return successfully even if the
backend ext4 filesystem has no space to store xattr key-value. That will
cause inconsistent behavior between front end and back end. The reason is
that lsetxattr will be triggered by p9_client_clunk, and unfortunately we
did not catch the error. This patch will catch the error to notify upper
caller.

p9_client_clunk (in 9p)
  p9_client_rpc(clnt, P9_TCLUNK, "d", fid->fid);
    v9fs_clunk (in qemu)
      put_fid
        free_fid
          v9fs_xattr_fid_clunk
            v9fs_co_lsetxattr
              s->ops->lsetxattr
                ext4_xattr_user_set (in host ext4 filesystem)

Signed-off-by: Jun Piao <piaojun@huawei.com>
---
 fs/9p/xattr.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c
index f329eee..352abc3 100644
--- a/fs/9p/xattr.c
+++ b/fs/9p/xattr.c
@@ -105,7 +105,7 @@ int v9fs_fid_xattr_set(struct p9_fid *fid, const char *name,
 {
 	struct kvec kvec = {.iov_base = (void *)value, .iov_len = value_len};
 	struct iov_iter from;
-	int retval;
+	int retval, err;

 	iov_iter_kvec(&from, WRITE | ITER_KVEC, &kvec, 1, value_len);

@@ -126,7 +126,9 @@ int v9fs_fid_xattr_set(struct p9_fid *fid, const char *name,
 			 retval);
 	else
 		p9_client_write(fid, 0, &from, &retval);
-	p9_client_clunk(fid);
+	err = p9_client_clunk(fid);
+	if (!retval && err)
+		retval = err;
 	return retval;
 }

-- 

             reply	other threads:[~2018-07-25  3:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25  3:13 piaojun [this message]
2018-07-25  3:32 ` [PATCH] fs/9p/xattr.c: catch the error of p9_client_clunk when setting xattr failed Dominique Martinet
2018-07-25  3:58   ` piaojun
2018-07-25  4:06     ` Dominique Martinet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5B57EACC.2060900@huawei.com \
    --to=piaojun@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=asmadeus@codewreck.org \
    --cc=ericvh@gmail.com \
    --cc=groug@kaod.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=rminnich@sandia.gov \
    --cc=v9fs-developer@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox