Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 842

kernel-2.6.18-238.el5.src.rpm

From: Eric Sandeen <sandeen@redhat.com>
Date: Tue, 8 Jul 2008 15:36:08 -0500
Subject: [fs] add clear_nlink, drop_nlink
Message-id: 4873CFB8.7040807@redhat.com
O-Subject: [PATCH RHEL5 9/9] clear_nlink, drop_nlink
Bugzilla: 443896
RH-Acked-by: Jeff Layton <jlayton@redhat.com>
RH-Acked-by: Jeff Moyer <jmoyer@redhat.com>
RH-Acked-by: Alexander Viro <aviro@redhat.com>

This is for:

Bugzilla Bug 443896: RFE: [Ext4 enabler] backport vfs
helpers to facilitate ext4 backport and testing

From: Dave Hansen <haveblue@us.ibm.com>
Date: Sun, 24 Jun 2007 00:16:42 +0000 (-0700)
Subject: document nlink function
X-Git-Tag: v2.6.22-rc6~11
X-Git-Url: http://git.engineering.redhat.com/?p=linux-2.6.git;a=commitdiff_plain;h=71c42157904404a37f89fff3b2536c55115823a5

document nlink function

These should have been documented from the beginning.  Fix it.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 2738e80..e8aaa5b 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -32,17 +32,6 @@
 #include <linux/buffer_head.h>
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
-static inline void clear_nlink(struct inode *inode)
-{
-	inode->i_nlink = 0;
-}
-static inline void drop_nlink(struct inode *inode)
-{
-	inode->i_nlink--;
-}
-#endif
-
 
 int cifs_get_inode_info_unix(struct inode **pinode,
 	const unsigned char *search_path, struct super_block *sb, int xid)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 18a1fa5..2525ea6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1217,6 +1217,14 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
 	__mark_inode_dirty(inode, I_DIRTY_SYNC);
 }
 
+/**
+ * inc_nlink - directly increment an inode's link count
+ * @inode: inode
+ *
+ * This is a low-level filesystem helper to replace any
+ * direct filesystem manipulation of i_nlink.  Currently,
+ * it is only here for parity with dec_nlink().
+ */
 static inline void inc_nlink(struct inode *inode)
 {
 	inode->i_nlink++;
@@ -1228,9 +1236,39 @@ static inline void inode_inc_link_count(struct inode *inode)
 	mark_inode_dirty(inode);
 }
 
-static inline void inode_dec_link_count(struct inode *inode)
+/**
+ * drop_nlink - directly drop an inode's link count
+ * @inode: inode
+ *
+ * This is a low-level filesystem helper to replace any
+ * direct filesystem manipulation of i_nlink.  In cases
+ * where we are attempting to track writes to the
+ * filesystem, a decrement to zero means an imminent
+ * write when the file is truncated and actually unlinked
+ * on the filesystem.
+ */
+static inline void drop_nlink(struct inode *inode)
 {
 	inode->i_nlink--;
+}
+
+/**
+ * clear_nlink - directly zero an inode's link count
+ * @inode: inode
+ *
+ * This is a low-level filesystem helper to replace any
+ * direct filesystem manipulation of i_nlink.  See
+ * drop_nlink() for why we care about i_nlink hitting zero.
+ */
+static inline void clear_nlink(struct inode *inode)
+{
+	inode->i_nlink = 0;
+}
+
+
+static inline void inode_dec_link_count(struct inode *inode)
+{
+	drop_nlink(inode);
 	mark_inode_dirty(inode);
 }