From: Christoph Rohland <cr@sap.com>
To: Uli Martens <u.martens@scientific.de>,
Linus Torvalds <torvalds@transmeta.com>,
Marcelo Tosatti <marcelo@conectiva.com.br>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [patch] tmpfs: incr. link-count on directory rename
Date: Tue, 19 Feb 2002 17:39:14 +0100 [thread overview]
Message-ID: <m3y9hpctot.fsf@linux.wdf.sap-ag.de> (raw)
In-Reply-To: <1013648840.2317.5.camel@isax> <20020214061933.GA17774@mentor.odyssey.cs.cmu.edu> <1013679241.20006.21.camel@pc-um>
In-Reply-To: <1013679241.20006.21.camel@pc-um> (Uli Martens's message of "14 Feb 2002 10:34:01 +0100")
Hi Uli,
On 14 Feb 2002, Uli Martens wrote:
> Oops, you're right, the linkcount of old_dir isn't decremented at
> the moment, too. I will test your patch this evening, but I think it
> looks better than mine... ;)
I prefer this one.
Linus, Marcelo, please apply.
The patch fixes the refcounting of directories on renames in tmpfs.
Greetings
Christoph
diff -uNr 18-rc1/mm/shmem.c c/mm/shmem.c
--- 18-rc1/mm/shmem.c Thu Jan 17 10:06:05 2002
+++ c/mm/shmem.c Tue Feb 19 17:31:23 2002
@@ -1083,19 +1083,25 @@
*/
static int shmem_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry)
{
- int error = -ENOTEMPTY;
+ struct inode *inode;
- if (shmem_empty(new_dentry)) {
- struct inode *inode = new_dentry->d_inode;
- if (inode) {
- inode->i_ctime = CURRENT_TIME;
- inode->i_nlink--;
- dput(new_dentry);
- }
- error = 0;
- old_dentry->d_inode->i_ctime = old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
+ if (!shmem_empty(new_dentry))
+ return -ENOTEMPTY;
+
+ inode = new_dentry->d_inode;
+ if (inode) {
+ inode->i_ctime = CURRENT_TIME;
+ inode->i_nlink--;
+ dput(new_dentry);
+ }
+ inode = old_dentry->d_inode;
+ if (S_ISDIR(inode->i_mode)) {
+ old_dir->i_nlink--;
+ new_dir->i_nlink++;
}
- return error;
+
+ inode->i_ctime = old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
+ return 0;
}
static int shmem_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
prev parent reply other threads:[~2002-02-20 8:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-14 1:07 [patch] tmpfs: incr. link-count on directory rename Uli Martens
2002-02-14 6:19 ` Jan Harkes
2002-02-14 9:34 ` Uli Martens
2002-02-19 16:39 ` Christoph Rohland [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3y9hpctot.fsf@linux.wdf.sap-ag.de \
--to=cr@sap.com \
--cc=jaharkes@cs.cmu.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--cc=torvalds@transmeta.com \
--cc=u.martens@scientific.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox