From patchwork Wed Oct 18 14:44:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Coddington X-Patchwork-Id: 10014879 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 AE650603FF for ; Wed, 18 Oct 2017 14:45:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A04F029300 for ; Wed, 18 Oct 2017 14:45:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9529D29306; Wed, 18 Oct 2017 14:45:01 +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 30C3B29304 for ; Wed, 18 Oct 2017 14:45:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751351AbdJROo7 (ORCPT ); Wed, 18 Oct 2017 10:44:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48660 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751243AbdJROo6 (ORCPT ); Wed, 18 Oct 2017 10:44:58 -0400 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 6B5CF1B5E47; Wed, 18 Oct 2017 14:44:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6B5CF1B5E47 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=bcodding@redhat.com Received: from bcodding.csb (ovpn-120-157.rdu2.redhat.com [10.10.120.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 204784388; Wed, 18 Oct 2017 14:44:58 +0000 (UTC) Received: by bcodding.csb (Postfix, from userid 24008) id 461EC10C3105; Wed, 18 Oct 2017 10:44:57 -0400 (EDT) From: Benjamin Coddington To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: Remove the flock check for matching open mode Date: Wed, 18 Oct 2017 10:44:57 -0400 Message-Id: <1c7f83fe32ca8699c745629a3ad0581c7f75b1ee.1508337840.git.bcodding@redhat.com> 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.30]); Wed, 18 Oct 2017 14:44:58 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit e12937279c8b "NFS: Move the flock open mode check into nfs_flock()" changed NFSv3 behavior for flock() such that the open mode must match the lock type, however this requirement shouldn't be enforced for flock(). Since FL_POSIX locks are already checked in fs/locks.c, remove this check in NFS altogether. For NFSv4, allow the server to determine whether or not the mode should match the lock type for flock(). Suggested-by: Trond Myklebust Signed-off-by: Benjamin Coddington --- fs/nfs/file.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index af330c31f627..ca7e737810e4 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -822,22 +822,8 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) if (NFS_SERVER(inode)->flags & NFS_MOUNT_LOCAL_FLOCK) is_local = 1; - /* - * VFS doesn't require the open mode to match a flock() lock's type. - * NFS, however, may simulate flock() locking with posix locking which - * requires the open mode to match the lock type. - */ - switch (fl->fl_type) { - case F_UNLCK: + if (fl->fl_type == F_UNLCK) return do_unlk(filp, cmd, fl, is_local); - case F_RDLCK: - if (!(filp->f_mode & FMODE_READ)) - return -EBADF; - break; - case F_WRLCK: - if (!(filp->f_mode & FMODE_WRITE)) - return -EBADF; - } return do_setlk(filp, cmd, fl, is_local); }