Root/target/linux/generic/patches-3.7/506-yaffs-3.2-dont-use-i_nlink-directly.patch

1--- a/fs/yaffs2/yaffs_vfs_glue.c
2+++ b/fs/yaffs2/yaffs_vfs_glue.c
3@@ -220,6 +220,29 @@ static struct inode *yaffs_iget(struct s
4 #define yaffs_SuperToDevice(sb) ((yaffs_dev_t *)sb->u.generic_sbp)
5 #endif
6 
7+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0))
8+static inline void yaffs_set_nlink(struct inode *inode, unsigned int nlink)
9+{
10+ set_nlink(inode, nlink);
11+}
12+
13+static inline void yaffs_dec_link_count(struct inode *inode)
14+{
15+ inode_dec_link_count(inode);
16+}
17+#else
18+static inline void yaffs_set_nlink(struct inode *inode, unsigned int nlink)
19+{
20+ inode->i_nlink = nlink;
21+}
22+
23+static inline void yaffs_dec_link_count(struct inode *inode)
24+{
25+ inode->i_nlink--;
26+ mark_inode_dirty(inode)
27+}
28+#endif
29+
30 
31 #define update_dir_time(dir) do {\
32             (dir)->i_ctime = (dir)->i_mtime = CURRENT_TIME; \
33@@ -1362,7 +1385,7 @@ static void yaffs_fill_inode_from_obj(st
34         inode->i_size = yaffs_get_obj_length(obj);
35         inode->i_blocks = (inode->i_size + 511) >> 9;
36 
37- inode->i_nlink = yaffs_get_obj_link_count(obj);
38+ yaffs_set_nlink(inode, yaffs_get_obj_link_count(obj));
39 
40         T(YAFFS_TRACE_OS,
41             (TSTR("yaffs_fill_inode mode %x uid %d gid %d size %d count %d\n"),
42@@ -1784,10 +1807,9 @@ static int yaffs_unlink(struct inode *di
43     retVal = yaffs_unlinker(obj, dentry->d_name.name);
44 
45     if (retVal == YAFFS_OK) {
46- dentry->d_inode->i_nlink--;
47+ yaffs_dec_link_count(dentry->d_inode);
48         dir->i_version++;
49         yaffs_gross_unlock(dev);
50- mark_inode_dirty(dentry->d_inode);
51         update_dir_time(dir);
52         return 0;
53     }
54@@ -1818,7 +1840,8 @@ static int yaffs_link(struct dentry *old
55             obj);
56 
57     if (link) {
58- old_dentry->d_inode->i_nlink = yaffs_get_obj_link_count(obj);
59+ yaffs_set_nlink(old_dentry->d_inode,
60+ yaffs_get_obj_link_count(obj));
61         d_instantiate(dentry, old_dentry->d_inode);
62         atomic_inc(&old_dentry->d_inode->i_count);
63         T(YAFFS_TRACE_OS,
64@@ -1937,11 +1960,9 @@ static int yaffs_rename(struct inode *ol
65     yaffs_gross_unlock(dev);
66 
67     if (retVal == YAFFS_OK) {
68- if (target) {
69- new_dentry->d_inode->i_nlink--;
70- mark_inode_dirty(new_dentry->d_inode);
71- }
72-
73+ if (target)
74+ yaffs_dec_link_count(new_dentry->d_inode);
75+
76         update_dir_time(old_dir);
77         if(old_dir != new_dir)
78             update_dir_time(new_dir);
79

Archive Download this file



interactive