diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-10-02 12:07:22 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-10-08 08:36:58 +0200 |
commit | 35197571a859dc268671341530c4e8606cebf901 (patch) | |
tree | b48da536610cf7806e5392b49ef402932a011bc5 | |
parent | 22d8660e7b77250a12ecf76dc4f20588e3f9257e (diff) | |
download | barebox-35197571a859dc268671341530c4e8606cebf901.tar.gz barebox-35197571a859dc268671341530c4e8606cebf901.tar.xz |
fs: implement clear_nlink and set_nlink
Implement clear_nlink and set_nlink and remove the private versions
from UBIFS.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | fs/fs.c | 16 | ||||
-rw-r--r-- | fs/ubifs/super.c | 35 | ||||
-rw-r--r-- | include/linux/fs.h | 2 |
3 files changed, 18 insertions, 35 deletions
@@ -1017,6 +1017,22 @@ void inc_nlink(struct inode *inode) inode->__i_nlink++; } +void clear_nlink(struct inode *inode) +{ + if (inode->i_nlink) { + inode->__i_nlink = 0; + } +} + +void set_nlink(struct inode *inode, unsigned int nlink) +{ + if (!nlink) { + clear_nlink(inode); + } else { + inode->__i_nlink = nlink; + } +} + static struct inode *alloc_inode(struct super_block *sb) { static const struct inode_operations empty_iops; diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 8bd1803bce..24b2c87248 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -63,41 +63,6 @@ int ubifs_iput(struct inode *inode) return 0; } -/* from fs/inode.c */ -/** - * 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. - */ -void clear_nlink(struct inode *inode) -{ - if (inode->i_nlink) { - inode->__i_nlink = 0; - } -} -EXPORT_SYMBOL(clear_nlink); - -/** - * set_nlink - directly set an inode's link count - * @inode: inode - * @nlink: new nlink (should be non-zero) - * - * This is a low-level filesystem helper to replace any - * direct filesystem manipulation of i_nlink. - */ -void set_nlink(struct inode *inode, unsigned int nlink) -{ - if (!nlink) { - clear_nlink(inode); - } else { - inode->__i_nlink = nlink; - } -} -EXPORT_SYMBOL(set_nlink); - /* from include/linux/fs.h */ static inline void i_uid_write(struct inode *inode, uid_t uid) { diff --git a/include/linux/fs.h b/include/linux/fs.h index d38dc12872..a72bc066c3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -411,6 +411,8 @@ unsigned int get_next_ino(void); void iput(struct inode *); struct inode *iget(struct inode *); void inc_nlink(struct inode *inode); +void clear_nlink(struct inode *inode); +void set_nlink(struct inode *inode, unsigned int nlink); struct inode_operations { struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); |