From patchwork Wed Jul 18 15:48:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1211941 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 4BC4A3FD4F for ; Wed, 18 Jul 2012 15:50:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754067Ab2GRPuF (ORCPT ); Wed, 18 Jul 2012 11:50:05 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:57672 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754054Ab2GRPuF (ORCPT ); Wed, 18 Jul 2012 11:50:05 -0400 Received: by mail-lb0-f174.google.com with SMTP id gm6so2257593lbb.19 for ; Wed, 18 Jul 2012 08:50:04 -0700 (PDT) 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=hhrrZHlpOw1E4YLjarmCWUwMh1bOm+LJbVIsT3QPVK4=; b=iitw/SYvWdZR0m1FF5z7SBtIwjSzGsa1s/3XRBs3kE3PUIjloBGn+M9+jq8z7DSJU4 8b4S0e7FnxcDInTQIZIviGE1Wjw5hfIw/NpVR6DyhfLR46MF7DbqFLOec3NWhGuvDWY+ tUQF0wNOuKonJueVYiUFGedelrnvuPSCu7Y31/qr7FVQ3t8Fw82fl2ZR9fqgJRzhiENt v09l9P5hmMtQ6b7HE0R1txs2N5HZEuafbaR4FPO+dWisntt+rFjoyIFUQNFI8HDcDjDj uWiNq2+rvpFd5ZmBCixwB09GJmJI3tMSw3716a3Zu5k0VEHeAX1hJGhJf2cDBr2aek1S hfBw== Received: by 10.152.125.116 with SMTP id mp20mr4061120lab.19.1342626604420; Wed, 18 Jul 2012 08:50:04 -0700 (PDT) Received: from localhost.localdomain ([178.45.208.11]) by mx.google.com with ESMTPS id p2sm4826985lbj.4.2012.07.18.08.50.02 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Jul 2012 08:50:03 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 07/45] CIFS: Protect i_nlink from being negative Date: Wed, 18 Jul 2012 19:48:23 +0400 Message-Id: <1342626541-29872-8-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1342626541-29872-1-git-send-email-pshilovsky@samba.org> References: <1342626541-29872-1-git-send-email-pshilovsky@samba.org> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org that can cause warning messages. Signed-off-by: Pavel Shilovsky --- fs/cifs/inode.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 7354877..88afb1a 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -1110,6 +1110,15 @@ undo_setattr: goto out_close; } +/* copied from fs/nfs/dir.c with small changes */ +static void +cifs_drop_nlink(struct inode *inode) +{ + spin_lock(&inode->i_lock); + if (inode->i_nlink > 0) + drop_nlink(inode); + spin_unlock(&inode->i_lock); +} /* * If dentry->d_inode is null (usually meaning the cached dentry @@ -1166,13 +1175,13 @@ retry_std_delete: psx_del_no_retry: if (!rc) { if (inode) - drop_nlink(inode); + cifs_drop_nlink(inode); } else if (rc == -ENOENT) { d_drop(dentry); } else if (rc == -ETXTBSY) { rc = cifs_rename_pending_delete(full_path, dentry, xid); if (rc == 0) - drop_nlink(inode); + cifs_drop_nlink(inode); } else if ((rc == -EACCES) && (dosattr == 0) && inode) { attrs = kzalloc(sizeof(*attrs), GFP_KERNEL); if (attrs == NULL) {