From patchwork Thu Feb 27 21:09:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11409809 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F35614BC for ; Thu, 27 Feb 2020 21:22:56 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 538E5246A0 for ; Thu, 27 Feb 2020 21:22:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 538E5246A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2B994348973; Thu, 27 Feb 2020 13:21:14 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 309A521FA64 for ; Thu, 27 Feb 2020 13:18:38 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 1B570EDA; Thu, 27 Feb 2020 16:18:14 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 19D71468; Thu, 27 Feb 2020 16:18:14 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:09:02 -0500 Message-Id: <1582838290-17243-75-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 074/622] lustre: llite: handle zero length xattr values correctly X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: "John L. Hammond" In mdt_getxattr(), set OBD_MD_FLXATTR in mbo_valid of the reply's MDT body so that the client can distinguish between nonexistent extended attributes and zero length values. In ll_xattr_list() and ll_getxattr_common() test for OBD_MD_FLXATTR and return 0 rather than -ENODATA in the appropriate cases. Add sanity test_102t() to test that zero length values are handled correctly. Lustre-commit: 1e4164a1254d ("LU-11109 mdt: handle zero length xattr values correctly") Signed-off-by: John L. Hammond Reviewed-on: https://review.whamcloud.com/32755 Reviewed-by: Andreas Dilger Reviewed-by: Mikhail Pershin Reviewed-by: James Simmons Signed-off-by: James Simmons --- fs/lustre/llite/xattr.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/fs/lustre/llite/xattr.c b/fs/lustre/llite/xattr.c index f25ae59..636334e 100644 --- a/fs/lustre/llite/xattr.c +++ b/fs/lustre/llite/xattr.c @@ -363,6 +363,11 @@ int ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer, /* only detect the xattr size */ if (size == 0) { + /* LU-11109: Older MDTs do not distinguish + * between nonexistent xattrs and zero length + * values in this case. Newer MDTs will return + * -ENODATA or set OBD_MD_FLXATTR. + */ rc = body->mbo_eadatasize; goto out; } @@ -375,7 +380,22 @@ int ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer, } if (body->mbo_eadatasize == 0) { - rc = -ENODATA; + /* LU-11109: Newer MDTs set OBD_MD_FLXATTR on + * success so that we can distinguish between + * zero length value and nonexistent xattr. + * + * If OBD_MD_FLXATTR is not set then we keep + * the old behavior and return -ENODATA for + * getxattr() when mbo_eadatasize is 0. But + * -ENODATA only makes sense for getxattr() + * and not for listxattr(). + */ + if (body->mbo_valid & OBD_MD_FLXATTR) + rc = 0; + else if (valid == OBD_MD_FLXATTR) + rc = -ENODATA; + else + rc = 0; goto out; }