From patchwork Tue Nov 27 06:50:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1808971 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 1B352DF254 for ; Tue, 27 Nov 2012 06:50:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758024Ab2K0Guu (ORCPT ); Tue, 27 Nov 2012 01:50:50 -0500 Received: from mail-la0-f46.google.com ([209.85.215.46]:54770 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757842Ab2K0Guu (ORCPT ); Tue, 27 Nov 2012 01:50:50 -0500 Received: by mail-la0-f46.google.com with SMTP id p5so6483184lag.19 for ; Mon, 26 Nov 2012 22:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=mGNHs/YytbNL0Bdg8bbWiet6Lw6WUMmOwu+695Nvv78=; b=Sh1vtZNSVbvHOM+wcE02wK8IPPhcN/5Uk9G4Pp6VE24S/RBa8JZWUooqO/pPCMLM4B utVgXE6iwyrdZlM3lnkh6p9Ip9eFGwp4Bv5ayp6CICdJDEmFqVN+3w9cL0IjeW35kiSd sCv021buiUQHfihpRmiBXodYX39QyuO9DgsMmOzvSauiGgfZW4elBgIR7CBoceHRLC64 eUmXYycoWQPmdCk/YlfzPqlbDi+H02RMEAE6dDgyBf/TvdwfS0vbwI1x9PKV5tgsbaoi 6igtHpqFWxvxyIu17jE2Z7VPZfK8YcSBmSolv6AC5kKWEfHkGuiqwRIgxsLF3qUDuEGE LHQw== Received: by 10.112.14.107 with SMTP id o11mr6153245lbc.98.1353999049471; Mon, 26 Nov 2012 22:50:49 -0800 (PST) Received: from localhost.localdomain ([95.84.0.69]) by mx.google.com with ESMTPS id bf3sm6547215lbb.16.2012.11.26.22.50.47 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 22:50:47 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 4/5] CIFS: Fix lock consistensy bug in cifs_setlk Date: Tue, 27 Nov 2012 10:50:27 +0400 Message-Id: <1353999029-3975-5-git-send-email-piastry@etersoft.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1353999029-3975-1-git-send-email-piastry@etersoft.ru> References: <1353999029-3975-1-git-send-email-piastry@etersoft.ru> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org If we netogiate mandatory locking style, have a read lock and try to set a write lock we end up with a write lock in vfs cache and no lock in cifs lock cache - that's wrong. Fix it by returning from cifs_setlk immediately if a error occurs during setting a lock. Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index a18c9eb..f8fe1bd 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1449,16 +1449,18 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, return -ENOMEM; rc = cifs_lock_add_if(cfile, lock, wait_flag); - if (rc < 0) + if (rc < 0) { kfree(lock); - if (rc <= 0) + return rc; + } + if (!rc) goto out; rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, type, 1, 0, wait_flag); if (rc) { kfree(lock); - goto out; + return rc; } cifs_lock_add(cfile, lock);