[Yaffs] [YAFFS 08/10] Don't update i_nlink directly

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Waldemar Rymarkiewicz
Date:  
To: yaffs
CC: Waldemar Rymarkiewicz, manningc2
Old-Topics: [Yaffs] [YAFFS 00/10] Add support of v3.2 kernel in single flavour of yaffs
Subject: [Yaffs] [YAFFS 08/10] Don't update i_nlink directly
Replace direct i_nlink updates with a new set_nlink() and inode_dec_link_count()

Signed-off-by: Waldemar Rymarkiewicz <>
---
yaffs_vfs_single.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/yaffs_vfs_single.c b/yaffs_vfs_single.c
index 70d1fd5..21de368 100644
--- a/yaffs_vfs_single.c
+++ b/yaffs_vfs_single.c
@@ -306,7 +306,7 @@ static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
                    obj);


     if (link) {
-        old_dentry->d_inode->i_nlink = yaffs_get_obj_link_count(obj);
+        set_nlink(old_dentry->d_inode, yaffs_get_obj_link_count(obj));
         d_instantiate(dentry, old_dentry->d_inode);
         atomic_inc(&old_dentry->d_inode->i_count);
         yaffs_trace(YAFFS_TRACE_OS,
@@ -426,10 +426,9 @@ static int yaffs_unlink(struct inode *dir, struct dentry *dentry)
     ret_val = yaffs_unlinker(obj, dentry->d_name.name);


     if (ret_val == YAFFS_OK) {
-        dentry->d_inode->i_nlink--;
+        inode_dec_link_count(dentry->d_inode);
         dir->i_version++;
         yaffs_gross_unlock(dev);
-        mark_inode_dirty(dentry->d_inode);
         update_dir_time(dir);
         return 0;
     }
@@ -493,10 +492,8 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
     yaffs_gross_unlock(dev);


     if (ret_val == YAFFS_OK) {
-        if (target) {
-            new_dentry->d_inode->i_nlink--;
-            mark_inode_dirty(new_dentry->d_inode);
-        }
+        if (target)
+            inode_dec_link_count(new_dentry->d_inode);


         update_dir_time(old_dir);
         if (old_dir != new_dir)
@@ -1880,7 +1877,7 @@ static void yaffs_fill_inode_from_obj(struct inode *inode,
     inode->i_ctime.tv_nsec = 0;
     inode->i_size = yaffs_get_obj_length(obj);
     inode->i_blocks = (inode->i_size + 511) >> 9;
-    inode->i_nlink = yaffs_get_obj_link_count(obj);
+    set_nlink(inode, yaffs_get_obj_link_count(obj));
     yaffs_trace(YAFFS_TRACE_OS,
         "yaffs_fill_inode mode %x uid %d gid %d size %d count %d",
         inode->i_mode, inode->i_uid, inode->i_gid,
-- 
1.7.8