From patchwork Thu Jan 17 16:52:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1997101 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0B4CD3FE1B for ; Thu, 17 Jan 2013 16:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752446Ab3AQQxS (ORCPT ); Thu, 17 Jan 2013 11:53:18 -0500 Received: from mail-la0-f46.google.com ([209.85.215.46]:54522 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751960Ab3AQQxR (ORCPT ); Thu, 17 Jan 2013 11:53:17 -0500 Received: by mail-la0-f46.google.com with SMTP id fq12so435242lab.33 for ; Thu, 17 Jan 2013 08:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer; bh=iBRjZ7bYPZ/dLlo/YoQAPmuElrWDAin8yK44NQ7mTIg=; b=lVBz6aV4BSJx2g+zo9gG2HO309R7DbIUSHo9ZkZNrMa+0vLRKv35Tfm9FcvnAzC+tu R+93n/jo9ndjEnwtJJcsKWqUgsrJx8ylnTaro23rV2xBSHEY0nCB+QecoN/Mk0gqGqEb FcSQvrRN0R1VV08NvqfmWJzADH99OS9vqsUHjHZODVB2F02xlVCT9dHpdRPetPhYZxJA nCINL4tODrVcOqcre+tZ7j/XQ0Oy1CsZJQMK41JHbs7ZSnIfde3D3em440VeVTAQiYAe 7Mj8xhFemAOsS1LeYtSIncq1fZKHHLTxmfo/NxX/+PQDiL0tX0Yp+hL/ZC4eaV9Y896L TJuA== X-Received: by 10.112.40.104 with SMTP id w8mr2556622lbk.114.1358441595171; Thu, 17 Jan 2013 08:53:15 -0800 (PST) Received: from builder.office.etersoft.ru (pritvor.etersoft.ru. [91.232.225.2]) by mx.google.com with ESMTPS id z4sm1067635lbn.17.2013.01.17.08.53.12 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Jan 2013 08:53:13 -0800 (PST) From: Pavel Shilovsky To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, wine-devel@winehq.org Subject: [PATCH v2 1/8] locks: make flock_lock_file take is_conflict callback parm Date: Thu, 17 Jan 2013 20:52:57 +0400 Message-Id: <1358441584-8783-1-git-send-email-piastry@etersoft.ru> X-Mailer: git-send-email 1.8.1.1 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org This parm demetermines how to check if locks have conflicts. This let us use flock_lock_file funtions further to add O_DENY* flags support through flocks. Signed-off-by: Pavel Shilovsky --- fs/locks.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index a94e331..9edfec4 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -697,14 +697,20 @@ static int posix_locks_deadlock(struct file_lock *caller_fl, return 0; } -/* Try to create a FLOCK lock on filp. We always insert new FLOCK locks +/* + * Try to create a FLOCK lock on filp. We always insert new FLOCK locks * after any leases, but before any posix locks. * * Note that if called with an FL_EXISTS argument, the caller may determine * whether or not a lock was successfully freed by testing the return * value for -ENOENT. + * + * Take @is_conflict callback that determines how to check if locks have + * conflicts or not. */ -static int flock_lock_file(struct file *filp, struct file_lock *request) +static int +flock_lock_file(struct file *filp, struct file_lock *request, + int (*is_conflict)(struct file_lock *, struct file_lock *)) { struct file_lock *new_fl = NULL; struct file_lock **before; @@ -760,7 +766,7 @@ find_conflict: break; if (IS_LEASE(fl)) continue; - if (!flock_locks_conflict(request, fl)) + if (!is_conflict(request, fl)) continue; error = -EAGAIN; if (!(request->fl_flags & FL_SLEEP)) @@ -1589,7 +1595,7 @@ int flock_lock_file_wait(struct file *filp, struct file_lock *fl) int error; might_sleep(); for (;;) { - error = flock_lock_file(filp, fl); + error = flock_lock_file(filp, fl, flock_locks_conflict); if (error != FILE_LOCK_DEFERRED) break; error = wait_event_interruptible(fl->fl_wait, !fl->fl_next);