Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp322149imm; Tue, 24 Jul 2018 20:15:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2ig0IZnZQy7DsDDeyCSPcD9dVge76BT7ibYOxnFzY3Y1jYEw2oNkSpzqtrXhckzuxCKPj X-Received: by 2002:a17:902:342:: with SMTP id 60-v6mr2425773pld.15.1532488527141; Tue, 24 Jul 2018 20:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532488527; cv=none; d=google.com; s=arc-20160816; b=LYG3pK3k4I6uvngyYfa8DGV1WYDWmQLIvGKXrm69pheeaF9VszPCDlqTLXbDWs9sub Te6EX/SuojkheM382mgJSyGs9l8QarJ4/NVAcF7eMBKWAINN1EgapC3Izxqrjo0GR0Fi p4awx6x3WtlcL++vBu6fPoTCkYNyWDwg+tJiB0+gZ8iKwKycif+ziO8AkrrQC66McxP+ 5q3BAc2hwzIgylYaBDcrZy+wrCF2Yv8KCqX39crmJFlVZjMUIUYzvui3fy8KBJiJJWgc xUedlcyUAHqdtLFD0GLzgVTEcLCL9rT5jnL/uJ7OR6SIygjsdQFt40RsSQ3J0gE53aCs xJWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:from:cc:to :arc-authentication-results; bh=rhsdgPsz36VE32wkyP/sn5EUdfmDoDhZKgwGnXu+AfQ=; b=ue+EuydCgFi/AMu44vkiCejNddLaRvHK2tgYtxyHsnzPLEWpnDtUBQkQoFEMvO6pUq GgarMlCh35jK5Tz1hoVx8DksorADoJCeMkLnZS3NQWEWqVrM5t33Xm2O9n4Y2RmjXJB4 +W7OpM1pIWalek3YrlIRIrB37KqXm9GTqpXCahpoMhJINQiQeqTXD+QOHkcskk7Ep2Lo GzhjuugZpMa/llyxmpmzO0j2VGCBzmiwCIRubzalX0kxrtZw6SXobJP8SnbbT2zEEBeg ewHMeWOwV6eAA49rl5jVFQuj9Y5ypwLW8SOz9P0Brk+MVtdaUB9ve1ckDfJ+M/FwB7Dv ppvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d191-v6si13759136pga.157.2018.07.24.20.15.12; Tue, 24 Jul 2018 20:15:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727699AbeGYEXM (ORCPT + 99 others); Wed, 25 Jul 2018 00:23:12 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9715 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726660AbeGYEXM (ORCPT ); Wed, 25 Jul 2018 00:23:12 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2FB57A4780508; Wed, 25 Jul 2018 11:13:35 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.382.0; Wed, 25 Jul 2018 11:13:33 +0800 To: Dominique Martinet CC: "akpm@linux-foundation.org" , "Eric Van Hensbergen" , Ron Minnich , "Latchesar Ionkov" , Linux Kernel Mailing List , , From: piaojun Subject: [PATCH] fs/9p/xattr.c: catch the error of p9_client_clunk when setting xattr failed Message-ID: <5B57EACC.2060900@huawei.com> Date: Wed, 25 Jul 2018 11:13:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } --