All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] CIFS: Fix mkdir/rmdir bug for the non-POSIX case
@ 2012-02-09 18:08 Pavel Shilovsky
       [not found] ` <1328810892-21925-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Shilovsky @ 2012-02-09 18:08 UTC (permalink / raw)
  To: linux-cifs-u79uwXL29TY76Z2rM5mHXA

Currently we do inc_nlink/drop_nlink for a parent directory for every
mkdir and rmdir calls. That's wrong when POSIX extensions are disabled
because in this case a server doesn't do the same things and returns
the old value on the next QueryInfo request. As the result, we update
our value with the server one and then decrement it on every rmdir
call - go to negative nlink values.

Fix this by doing inc_nlink/drop_nlink for parent directory in mkdir
and rmdir in POSIX case only. Also add cERROR when nlink value <= 2
and we still try to decrement it (possible broken servers).

Signed-off-by: Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
---
 fs/cifs/inode.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index a5f54b7..9af6ec7 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1355,11 +1355,11 @@ mkdir_retry_old:
 		d_drop(direntry);
 	} else {
 mkdir_get_info:
-		inc_nlink(inode);
-		if (pTcon->unix_ext)
+		if (pTcon->unix_ext) {
+			inc_nlink(inode);
 			rc = cifs_get_inode_info_unix(&newinode, full_path,
 						      inode->i_sb, xid);
-		else
+		} else
 			rc = cifs_get_inode_info(&newinode, full_path, NULL,
 						 inode->i_sb, xid, NULL);
 
@@ -1475,7 +1475,13 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
 	cifs_put_tlink(tlink);
 
 	if (!rc) {
-		drop_nlink(inode);
+		if (pTcon->unix_ext) {
+			if (inode->i_nlink > 2)
+				drop_nlink(inode);
+			else
+				cERROR(1, "%s: unexpected nlink number(%u)",
+				       __func__, inode->i_nlink);
+		}
 		spin_lock(&direntry->d_inode->i_lock);
 		i_size_write(direntry->d_inode, 0);
 		clear_nlink(direntry->d_inode);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-02-16 10:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-09 18:08 [PATCH] CIFS: Fix mkdir/rmdir bug for the non-POSIX case Pavel Shilovsky
     [not found] ` <1328810892-21925-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-02-10  2:15   ` Shirish Pargaonkar
     [not found]     ` <CADT32e+BPaJebN=tz27pGh-=sTwvyszBK1F9E7LVKrvFpxb0Zw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-10  6:11       ` Pavel Shilovsky
2012-02-10 18:22   ` Jeff Layton
     [not found]     ` <20120210132216.03badf59-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-02-12 18:47       ` Pavel Shilovsky
2012-02-13  7:26       ` Suresh Jayaraman
     [not found]         ` <4F38BB30.9030107-IBi9RG/b67k@public.gmane.org>
2012-02-13 13:35           ` Jeff Layton
     [not found]             ` <20120213083544.486aa192-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-02-13 16:00               ` Steve French
     [not found]                 ` <CAH2r5msQm=3EAqBmjHqWVHP2Gu_X8UMhwcjfC8agqvvc1boEsg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-15 18:09                   ` Pavel Shilovsky
     [not found]                     ` <CAKywueR7Lyy63SJpQS8au=_EDzYGDJHKA0U9KOpxneyk2V9t8g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-16 10:51                       ` Jeff Layton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.