From patchwork Wed Dec 13 11:05:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 10109757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3195D602C2 for ; Wed, 13 Dec 2017 11:05:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2350928FEB for ; Wed, 13 Dec 2017 11:05:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 180AB29125; Wed, 13 Dec 2017 11:05:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00E9829072 for ; Wed, 13 Dec 2017 11:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218AbdLMLFa (ORCPT ); Wed, 13 Dec 2017 06:05:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38276 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751529AbdLMLFa (ORCPT ); Wed, 13 Dec 2017 06:05:30 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E5D1AC0587D2; Wed, 13 Dec 2017 11:05:29 +0000 (UTC) Received: from localhost (unknown [10.66.12.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F49A7D8E3; Wed, 13 Dec 2017 11:05:29 +0000 (UTC) Date: Wed, 13 Dec 2017 19:05:27 +0800 From: Eryu Guan To: Goldwyn Rodrigues Cc: fstests@vger.kernel.org, darrick.wong@oracle.com, Goldwyn Rodrigues Subject: Re: [PATCH v4 1/3] Check pwrite parameters Message-ID: <20171213110527.GB2749@eguan.usersys.redhat.com> References: <20171207160044.8913-1-rgoldwyn@suse.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171207160044.8913-1-rgoldwyn@suse.de> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 13 Dec 2017 11:05:30 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Dec 07, 2017 at 10:00:42AM -0600, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues > > There are some parameters added with xfs_io. Check if the pwrite > parameters are available. For some cases, xfs_io now returns "command > -%c not supported", so added "not supported" to count as error. > > Signed-off-by: Goldwyn Rodrigues > > Changes since v3: > - pwrite -N check to add -V parameters to check on pwritev2() > > --- > common/rc | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/common/rc b/common/rc > index 4c053a53..4f4b9e10 100644 > --- a/common/rc > +++ b/common/rc > @@ -2035,6 +2035,7 @@ _require_xfs_io_command() > shift > local param="$*" > local param_checked=0 > + local opts="" > > testfile=$TEST_DIR/$$.xfs_io > case $command in > @@ -2079,6 +2080,17 @@ _require_xfs_io_command() > echo $testio | grep -q "invalid option" && \ > _notrun "xfs_io $command support is missing" > ;; > + "pwrite") > + # -N (RWF_NOWAIT) only works with direct I/O writes > + local pwrite_opts=" " > + if [ "$param" == "-N" ]; then > + opts+=" -d" > + pwrite_opts+="-V 1 -b 4k" > + fi > + testio=`$XFS_IO_PROG -f $opts -c \ > + "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1` > + param_checked=1 I think I found why xfs_io returned EOPNOTSUPP but strace showed EAGAIN for me. It's pwritev2 glibc wrapper that modifies the errno before return, please see glibc commit 852d63120783 ("posix: Set p{read,write}v2 to return ENOTSUP (BZ#21780)"). So originally, pritev2 wrapper returned any error except ENOSYS, but now it translates all errors to ENOTSUP (EOPNOTSUPP). That's why kernel returned EAGAIN and strace captured EAGAIN but perror() in xfs_io still printed EOPNOTSUPP. It looks like a glibc bug to me. Apparently, my Fedora rawhide system is new enough to have this glibc version. And I did see generic/470 pass with 4.15-rc2 kernel with that glibc patch reverted. Anyway, with this additional "-V 1" in pwrite test, generic/470 would _notrun on buggy system. I'll queue this patchset for next release if there's no more comments from other reivewers. Thanks Eryu > + ;; > "scrub"|"repair") > testio=`$XFS_IO_PROG -x -c "$command probe 0" $TEST_DIR 2>&1` > echo $testio | grep -q "Inappropriate ioctl" && \ > @@ -2109,7 +2121,9 @@ _require_xfs_io_command() > $XFS_IO_PROG -c "help $command" | grep -q "^ $param --" || \ > _notrun "xfs_io $command doesn't support $param" > else > - echo $testio | grep -q "invalid option" && \ > + # xfs_io could result in "command %c not supported" if it was > + # built on kernels not supporting pwritev2() calls > + echo $testio | grep -q "\(invalid option\|not supported\)" && \ > _notrun "xfs_io $command doesn't support $param" > fi > } > -- > 2.14.2 > --- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/sysdeps/unix/sysv/linux/pwritev2.c b/sysdeps/unix/sysv/linux/pwritev2.c index 72f0471f969a..8e5032fe2fed 100644 --- a/sysdeps/unix/sysv/linux/pwritev2.c +++ b/sysdeps/unix/sysv/linux/pwritev2.c @@ -28,7 +28,7 @@ pwritev2 (int fd, const struct iovec *vector, int count, off_t offset, # ifdef __NR_pwritev2 ssize_t result = SYSCALL_CANCEL (pwritev2, fd, vector, count, LO_HI_LONG (offset), flags); - if (result >= 0 || errno != ENOSYS) + if (result >= 0) return result; # endif /* Trying to emulate the pwritev2 syscall flags is troublesome: @@ -42,7 +42,7 @@ pwritev2 (int fd, const struct iovec *vector, int count, off_t offset, if (flags != 0) { - __set_errno (EOPNOTSUPP); + __set_errno (ENOTSUP); return -1; } return pwritev (fd, vector, count, offset);