aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h2
-rw-r--r--drivers/staging/lustre/lustre/include/linux/lvfs.h2
-rw-r--r--drivers/staging/lustre/lustre/include/lprocfs_status.h6
-rw-r--r--drivers/staging/lustre/lustre/llite/dcache.c8
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_internal.h4
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_lib.c2
-rw-r--r--drivers/staging/lustre/lustre/llite/namei.c4
-rw-r--r--drivers/staging/lustre/lustre/lvfs/lvfs_linux.c4
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lprocfs_status.c8
-rw-r--r--fs/autofs4/expire.c8
-rw-r--r--fs/autofs4/root.c2
-rw-r--r--fs/ceph/inode.c4
-rw-r--r--fs/ceph/mds_client.c2
-rw-r--r--fs/coda/dir.c2
-rw-r--r--fs/configfs/dir.c2
-rw-r--r--fs/ecryptfs/inode.c2
-rw-r--r--fs/f2fs/dir.c20
-rw-r--r--fs/locks.c71
-rw-r--r--fs/ncpfs/inode.c12
-rw-r--r--fs/nfs/dir.c6
-rw-r--r--fs/nfs/unlink.c2
-rw-r--r--fs/nilfs2/super.c2
-rw-r--r--fs/seq_file.c54
-rw-r--r--include/linux/dcache.h5
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/seq_file.h6
26 files changed, 169 insertions, 72 deletions
diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h
index f0508084e8c5..a8e9c0c8ffd2 100644
--- a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h
+++ b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h
@@ -60,8 +60,6 @@ truncate_complete_page(struct address_space *mapping, struct page *page)
60 ll_delete_from_page_cache(page); 60 ll_delete_from_page_cache(page);
61} 61}
62 62
63# define d_refcount(d) ((d)->d_count)
64
65#ifdef ATTR_OPEN 63#ifdef ATTR_OPEN
66# define ATTR_FROM_OPEN ATTR_OPEN 64# define ATTR_FROM_OPEN ATTR_OPEN
67#else 65#else
diff --git a/drivers/staging/lustre/lustre/include/linux/lvfs.h b/drivers/staging/lustre/lustre/include/linux/lvfs.h
index b4db6cb581bd..eb59ac7d5946 100644
--- a/drivers/staging/lustre/lustre/include/linux/lvfs.h
+++ b/drivers/staging/lustre/lustre/include/linux/lvfs.h
@@ -99,7 +99,7 @@ static inline void l_dput(struct dentry *de)
99 if (!de || IS_ERR(de)) 99 if (!de || IS_ERR(de))
100 return; 100 return;
101 //shrink_dcache_parent(de); 101 //shrink_dcache_parent(de);
102 LASSERT(d_refcount(de) > 0); 102 LASSERT(d_count(de) > 0);
103 dput(de); 103 dput(de);
104} 104}
105 105
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index e770d0260576..55f182205d78 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -53,7 +53,7 @@ struct lprocfs_vars {
53 /** 53 /**
54 * /proc file mode. 54 * /proc file mode.
55 */ 55 */
56 mode_t proc_mode; 56 umode_t proc_mode;
57}; 57};
58 58
59struct lprocfs_static_vars { 59struct lprocfs_static_vars {
@@ -600,11 +600,11 @@ extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
600extern int lprocfs_obd_cleanup(struct obd_device *obd); 600extern int lprocfs_obd_cleanup(struct obd_device *obd);
601 601
602extern int lprocfs_seq_create(proc_dir_entry_t *parent, const char *name, 602extern int lprocfs_seq_create(proc_dir_entry_t *parent, const char *name,
603 mode_t mode, 603 umode_t mode,
604 const struct file_operations *seq_fops, 604 const struct file_operations *seq_fops,
605 void *data); 605 void *data);
606extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name, 606extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
607 mode_t mode, 607 umode_t mode,
608 const struct file_operations *seq_fops, 608 const struct file_operations *seq_fops,
609 void *data); 609 void *data);
610 610
diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c
index 7d6abfff9740..ff0d085077c8 100644
--- a/drivers/staging/lustre/lustre/llite/dcache.c
+++ b/drivers/staging/lustre/lustre/llite/dcache.c
@@ -98,7 +98,7 @@ int ll_dcompare(const struct dentry *parent, const struct inode *pinode,
98 98
99 CDEBUG(D_DENTRY, "found name %.*s(%p) flags %#x refc %d\n", 99 CDEBUG(D_DENTRY, "found name %.*s(%p) flags %#x refc %d\n",
100 name->len, name->name, dentry, dentry->d_flags, 100 name->len, name->name, dentry, dentry->d_flags,
101 d_refcount(dentry)); 101 d_count(dentry));
102 102
103 /* mountpoint is always valid */ 103 /* mountpoint is always valid */
104 if (d_mountpoint((struct dentry *)dentry)) 104 if (d_mountpoint((struct dentry *)dentry))
@@ -165,7 +165,7 @@ static int ll_ddelete(const struct dentry *de)
165 list_empty(&de->d_subdirs) ? "" : "subdirs"); 165 list_empty(&de->d_subdirs) ? "" : "subdirs");
166 166
167 /* kernel >= 2.6.38 last refcount is decreased after this function. */ 167 /* kernel >= 2.6.38 last refcount is decreased after this function. */
168 LASSERT(d_refcount(de) == 1); 168 LASSERT(d_count(de) == 1);
169 169
170 /* Disable this piece of code temproarily because this is called 170 /* Disable this piece of code temproarily because this is called
171 * inside dcache_lock so it's not appropriate to do lots of work 171 * inside dcache_lock so it's not appropriate to do lots of work
@@ -190,7 +190,7 @@ static int ll_set_dd(struct dentry *de)
190 190
191 CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n", 191 CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n",
192 de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode, 192 de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
193 d_refcount(de)); 193 d_count(de));
194 194
195 if (de->d_fsdata == NULL) { 195 if (de->d_fsdata == NULL) {
196 struct ll_dentry_data *lld; 196 struct ll_dentry_data *lld;
@@ -540,7 +540,7 @@ out:
540 CDEBUG(D_DENTRY, "revalidated dentry %.*s (%p) parent %p " 540 CDEBUG(D_DENTRY, "revalidated dentry %.*s (%p) parent %p "
541 "inode %p refc %d\n", de->d_name.len, 541 "inode %p refc %d\n", de->d_name.len,
542 de->d_name.name, de, de->d_parent, de->d_inode, 542 de->d_name.name, de, de->d_parent, de->d_inode,
543 d_refcount(de)); 543 d_count(de));
544 544
545 ll_set_lock_data(exp, de->d_inode, it, &bits); 545 ll_set_lock_data(exp, de->d_inode, it, &bits);
546 546
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 992cd203ca1a..5227c5c4ebe2 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -1529,12 +1529,12 @@ static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
1529{ 1529{
1530 CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p " 1530 CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p "
1531 "refc %d\n", dentry->d_name.len, dentry->d_name.name, dentry, 1531 "refc %d\n", dentry->d_name.len, dentry->d_name.name, dentry,
1532 dentry->d_parent, dentry->d_inode, d_refcount(dentry)); 1532 dentry->d_parent, dentry->d_inode, d_count(dentry));
1533 1533
1534 spin_lock_nested(&dentry->d_lock, 1534 spin_lock_nested(&dentry->d_lock,
1535 nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL); 1535 nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
1536 __d_lustre_invalidate(dentry); 1536 __d_lustre_invalidate(dentry);
1537 if (d_refcount(dentry) == 0) 1537 if (d_count(dentry) == 0)
1538 __d_drop(dentry); 1538 __d_drop(dentry);
1539 spin_unlock(&dentry->d_lock); 1539 spin_unlock(&dentry->d_lock);
1540} 1540}
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 2311b20ee99a..afae8010623d 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -659,7 +659,7 @@ void lustre_dump_dentry(struct dentry *dentry, int recur)
659 " flags=0x%x, fsdata=%p, %d subdirs\n", dentry, 659 " flags=0x%x, fsdata=%p, %d subdirs\n", dentry,
660 dentry->d_name.len, dentry->d_name.name, 660 dentry->d_name.len, dentry->d_name.name,
661 dentry->d_parent->d_name.len, dentry->d_parent->d_name.name, 661 dentry->d_parent->d_name.len, dentry->d_parent->d_name.name,
662 dentry->d_parent, dentry->d_inode, d_refcount(dentry), 662 dentry->d_parent, dentry->d_inode, d_count(dentry),
663 dentry->d_flags, dentry->d_fsdata, subdirs); 663 dentry->d_flags, dentry->d_fsdata, subdirs);
664 if (dentry->d_inode != NULL) 664 if (dentry->d_inode != NULL)
665 ll_dump_inode(dentry->d_inode); 665 ll_dump_inode(dentry->d_inode);
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 58d59aa12619..ff8f63de5612 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -409,7 +409,7 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
409 iput(inode); 409 iput(inode);
410 CDEBUG(D_DENTRY, 410 CDEBUG(D_DENTRY,
411 "Reuse dentry %p inode %p refc %d flags %#x\n", 411 "Reuse dentry %p inode %p refc %d flags %#x\n",
412 new, new->d_inode, d_refcount(new), new->d_flags); 412 new, new->d_inode, d_count(new), new->d_flags);
413 return new; 413 return new;
414 } 414 }
415 } 415 }
@@ -417,7 +417,7 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
417 __d_lustre_invalidate(de); 417 __d_lustre_invalidate(de);
418 d_add(de, inode); 418 d_add(de, inode);
419 CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n", 419 CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n",
420 de, de->d_inode, d_refcount(de), de->d_flags); 420 de, de->d_inode, d_count(de), de->d_flags);
421 return de; 421 return de;
422} 422}
423 423
diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c
index 1e6f32c3549b..e70d8fe99888 100644
--- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c
+++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c
@@ -121,8 +121,8 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
121 OBD_SET_CTXT_MAGIC(save); 121 OBD_SET_CTXT_MAGIC(save);
122 122
123 save->fs = get_fs(); 123 save->fs = get_fs();
124 LASSERT(d_refcount(cfs_fs_pwd(current->fs))); 124 LASSERT(d_count(cfs_fs_pwd(current->fs)));
125 LASSERT(d_refcount(new_ctx->pwd)); 125 LASSERT(d_count(new_ctx->pwd));
126 save->pwd = dget(cfs_fs_pwd(current->fs)); 126 save->pwd = dget(cfs_fs_pwd(current->fs));
127 save->pwdmnt = mntget(cfs_fs_mnt(current->fs)); 127 save->pwdmnt = mntget(cfs_fs_mnt(current->fs));
128 save->luc.luc_umask = current_umask(); 128 save->luc.luc_umask = current_umask();
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 3b157f89c300..f7af3d6a4efc 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -73,7 +73,7 @@ proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root,
73 struct file_operations *fops) 73 struct file_operations *fops)
74{ 74{
75 proc_dir_entry_t *proc; 75 proc_dir_entry_t *proc;
76 mode_t mode = 0; 76 umode_t mode = 0;
77 77
78 if (root == NULL || name == NULL || fops == NULL) 78 if (root == NULL || name == NULL || fops == NULL)
79 return ERR_PTR(-EINVAL); 79 return ERR_PTR(-EINVAL);
@@ -140,7 +140,7 @@ int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list,
140 140
141 while (list->name != NULL) { 141 while (list->name != NULL) {
142 struct proc_dir_entry *proc; 142 struct proc_dir_entry *proc;
143 mode_t mode = 0; 143 umode_t mode = 0;
144 144
145 if (list->proc_mode != 0000) { 145 if (list->proc_mode != 0000) {
146 mode = list->proc_mode; 146 mode = list->proc_mode;
@@ -1899,7 +1899,7 @@ EXPORT_SYMBOL(lprocfs_find_named_value);
1899 1899
1900int lprocfs_seq_create(proc_dir_entry_t *parent, 1900int lprocfs_seq_create(proc_dir_entry_t *parent,
1901 const char *name, 1901 const char *name,
1902 mode_t mode, 1902 umode_t mode,
1903 const struct file_operations *seq_fops, 1903 const struct file_operations *seq_fops,
1904 void *data) 1904 void *data)
1905{ 1905{
@@ -1919,7 +1919,7 @@ EXPORT_SYMBOL(lprocfs_seq_create);
1919 1919
1920int lprocfs_obd_seq_create(struct obd_device *dev, 1920int lprocfs_obd_seq_create(struct obd_device *dev,
1921 const char *name, 1921 const char *name,
1922 mode_t mode, 1922 umode_t mode,
1923 const struct file_operations *seq_fops, 1923 const struct file_operations *seq_fops,
1924 void *data) 1924 void *data)
1925{ 1925{
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 13ddec92341c..3d9d3f5d5dda 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -109,7 +109,7 @@ cont:
109 109
110 spin_lock_nested(&q->d_lock, DENTRY_D_LOCK_NESTED); 110 spin_lock_nested(&q->d_lock, DENTRY_D_LOCK_NESTED);
111 /* Already gone or negative dentry (under construction) - try next */ 111 /* Already gone or negative dentry (under construction) - try next */
112 if (q->d_count == 0 || !simple_positive(q)) { 112 if (!d_count(q) || !simple_positive(q)) {
113 spin_unlock(&q->d_lock); 113 spin_unlock(&q->d_lock);
114 next = q->d_u.d_child.next; 114 next = q->d_u.d_child.next;
115 goto cont; 115 goto cont;
@@ -267,7 +267,7 @@ static int autofs4_tree_busy(struct vfsmount *mnt,
267 else 267 else
268 ino_count++; 268 ino_count++;
269 269
270 if (p->d_count > ino_count) { 270 if (d_count(p) > ino_count) {
271 top_ino->last_used = jiffies; 271 top_ino->last_used = jiffies;
272 dput(p); 272 dput(p);
273 return 1; 273 return 1;
@@ -409,7 +409,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
409 if (!exp_leaves) { 409 if (!exp_leaves) {
410 /* Path walk currently on this dentry? */ 410 /* Path walk currently on this dentry? */
411 ino_count = atomic_read(&ino->count) + 1; 411 ino_count = atomic_read(&ino->count) + 1;
412 if (dentry->d_count > ino_count) 412 if (d_count(dentry) > ino_count)
413 goto next; 413 goto next;
414 414
415 if (!autofs4_tree_busy(mnt, dentry, timeout, do_now)) { 415 if (!autofs4_tree_busy(mnt, dentry, timeout, do_now)) {
@@ -423,7 +423,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
423 } else { 423 } else {
424 /* Path walk currently on this dentry? */ 424 /* Path walk currently on this dentry? */
425 ino_count = atomic_read(&ino->count) + 1; 425 ino_count = atomic_read(&ino->count) + 1;
426 if (dentry->d_count > ino_count) 426 if (d_count(dentry) > ino_count)
427 goto next; 427 goto next;
428 428
429 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now); 429 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index ca8e55548d98..92ef341ba0cf 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -179,7 +179,7 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
179 spin_lock(&active->d_lock); 179 spin_lock(&active->d_lock);
180 180
181 /* Already gone? */ 181 /* Already gone? */
182 if (active->d_count == 0) 182 if (!d_count(active))
183 goto next; 183 goto next;
184 184
185 qstr = &active->d_name; 185 qstr = &active->d_name;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index be0f7e20d62e..bd2289a4f40d 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -903,8 +903,8 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
903 } else if (realdn) { 903 } else if (realdn) {
904 dout("dn %p (%d) spliced with %p (%d) " 904 dout("dn %p (%d) spliced with %p (%d) "
905 "inode %p ino %llx.%llx\n", 905 "inode %p ino %llx.%llx\n",
906 dn, dn->d_count, 906 dn, d_count(dn),
907 realdn, realdn->d_count, 907 realdn, d_count(realdn),
908 realdn->d_inode, ceph_vinop(realdn->d_inode)); 908 realdn->d_inode, ceph_vinop(realdn->d_inode));
909 dput(dn); 909 dput(dn);
910 dn = realdn; 910 dn = realdn;
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 74fd2898b2ab..99890b02a10b 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1553,7 +1553,7 @@ retry:
1553 *base = ceph_ino(temp->d_inode); 1553 *base = ceph_ino(temp->d_inode);
1554 *plen = len; 1554 *plen = len;
1555 dout("build_path on %p %d built %llx '%.*s'\n", 1555 dout("build_path on %p %d built %llx '%.*s'\n",
1556 dentry, dentry->d_count, *base, len, path); 1556 dentry, d_count(dentry), *base, len, path);
1557 return path; 1557 return path;
1558} 1558}
1559 1559
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 14a14808320c..190effc6a6fa 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -526,7 +526,7 @@ static int coda_dentry_revalidate(struct dentry *de, unsigned int flags)
526 if (cii->c_flags & C_FLUSH) 526 if (cii->c_flags & C_FLUSH)
527 coda_flag_inode_children(inode, C_FLUSH); 527 coda_flag_inode_children(inode, C_FLUSH);
528 528
529 if (de->d_count > 1) 529 if (d_count(de) > 1)
530 /* pretend it's valid, but don't change the flags */ 530 /* pretend it's valid, but don't change the flags */
531 goto out; 531 goto out;
532 532
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 64e5323cbbb0..5e7c60c1cb63 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -387,7 +387,7 @@ static void remove_dir(struct dentry * d)
387 if (d->d_inode) 387 if (d->d_inode)
388 simple_rmdir(parent->d_inode,d); 388 simple_rmdir(parent->d_inode,d);
389 389
390 pr_debug(" o %s removing done (%d)\n",d->d_name.name, d->d_count); 390 pr_debug(" o %s removing done (%d)\n",d->d_name.name, d_count(d));
391 391
392 dput(parent); 392 dput(parent);
393} 393}
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index a2f2bb2c256d..67e9b6339691 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -358,7 +358,7 @@ static int ecryptfs_lookup_interpose(struct dentry *dentry,
358 358
359 lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent)); 359 lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent));
360 fsstack_copy_attr_atime(dir_inode, lower_dentry->d_parent->d_inode); 360 fsstack_copy_attr_atime(dir_inode, lower_dentry->d_parent->d_inode);
361 BUG_ON(!lower_dentry->d_count); 361 BUG_ON(!d_count(lower_dentry));
362 362
363 ecryptfs_set_dentry_private(dentry, dentry_info); 363 ecryptfs_set_dentry_private(dentry, dentry_info);
364 ecryptfs_set_dentry_lower(dentry, lower_dentry); 364 ecryptfs_set_dentry_lower(dentry, lower_dentry);
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 9d1cd423450d..62f0d5977c64 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -610,13 +610,12 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
610{ 610{
611 struct inode *inode = file_inode(file); 611 struct inode *inode = file_inode(file);
612 unsigned long npages = dir_blocks(inode); 612 unsigned long npages = dir_blocks(inode);
613 unsigned int bit_pos = 0, start_bit_pos = 0; 613 unsigned int bit_pos = 0;
614 struct f2fs_dentry_block *dentry_blk = NULL; 614 struct f2fs_dentry_block *dentry_blk = NULL;
615 struct f2fs_dir_entry *de = NULL; 615 struct f2fs_dir_entry *de = NULL;
616 struct page *dentry_page = NULL; 616 struct page *dentry_page = NULL;
617 unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK); 617 unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK);
618 unsigned char d_type = DT_UNKNOWN; 618 unsigned char d_type = DT_UNKNOWN;
619 int slots;
620 619
621 bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK); 620 bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK);
622 621
@@ -625,7 +624,6 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
625 if (IS_ERR(dentry_page)) 624 if (IS_ERR(dentry_page))
626 continue; 625 continue;
627 626
628 start_bit_pos = bit_pos;
629 dentry_blk = kmap(dentry_page); 627 dentry_blk = kmap(dentry_page);
630 while (bit_pos < NR_DENTRY_IN_BLOCK) { 628 while (bit_pos < NR_DENTRY_IN_BLOCK) {
631 bit_pos = find_next_bit_le(&dentry_blk->dentry_bitmap, 629 bit_pos = find_next_bit_le(&dentry_blk->dentry_bitmap,
@@ -634,19 +632,19 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
634 if (bit_pos >= NR_DENTRY_IN_BLOCK) 632 if (bit_pos >= NR_DENTRY_IN_BLOCK)
635 break; 633 break;
636 634
637 ctx->pos += bit_pos - start_bit_pos;
638 de = &dentry_blk->dentry[bit_pos]; 635 de = &dentry_blk->dentry[bit_pos];
639 if (de->file_type < F2FS_FT_MAX) 636 if (de->file_type < F2FS_FT_MAX)
640 d_type = f2fs_filetype_table[de->file_type]; 637 d_type = f2fs_filetype_table[de->file_type];
641 else 638 else
642 d_type = DT_UNKNOWN; 639 d_type = DT_UNKNOWN;
643 if (!dir_emit(ctx, 640 if (!dir_emit(ctx,
644 dentry_blk->filename[bit_pos], 641 dentry_blk->filename[bit_pos],
645 le16_to_cpu(de->name_len), 642 le16_to_cpu(de->name_len),
646 le32_to_cpu(de->ino), d_type)) 643 le32_to_cpu(de->ino), d_type))
647 goto success; 644 goto stop;
648 slots = GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); 645
649 bit_pos += slots; 646 bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
647 ctx->pos = n * NR_DENTRY_IN_BLOCK + bit_pos;
650 } 648 }
651 bit_pos = 0; 649 bit_pos = 0;
652 ctx->pos = (n + 1) * NR_DENTRY_IN_BLOCK; 650 ctx->pos = (n + 1) * NR_DENTRY_IN_BLOCK;
@@ -654,7 +652,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
654 f2fs_put_page(dentry_page, 1); 652 f2fs_put_page(dentry_page, 1);
655 dentry_page = NULL; 653 dentry_page = NULL;
656 } 654 }
657success: 655stop:
658 if (dentry_page && !IS_ERR(dentry_page)) { 656 if (dentry_page && !IS_ERR(dentry_page)) {
659 kunmap(dentry_page); 657 kunmap(dentry_page);
660 f2fs_put_page(dentry_page, 1); 658 f2fs_put_page(dentry_page, 1);
diff --git a/fs/locks.c b/fs/locks.c
index 04e2c1fdb157..b27a3005d78d 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -127,6 +127,8 @@
127#include <linux/rcupdate.h> 127#include <linux/rcupdate.h>
128#include <linux/pid_namespace.h> 128#include <linux/pid_namespace.h>
129#include <linux/hashtable.h> 129#include <linux/hashtable.h>
130#include <linux/percpu.h>
131#include <linux/lglock.h>
130 132
131#include <asm/uaccess.h> 133#include <asm/uaccess.h>
132 134
@@ -155,11 +157,13 @@ int lease_break_time = 45;
155 for (lockp = &inode->i_flock; *lockp != NULL; lockp = &(*lockp)->fl_next) 157 for (lockp = &inode->i_flock; *lockp != NULL; lockp = &(*lockp)->fl_next)
156 158
157/* 159/*
158 * The global file_lock_list is only used for displaying /proc/locks. Protected 160 * The global file_lock_list is only used for displaying /proc/locks, so we
159 * by the file_lock_lock. 161 * keep a list on each CPU, with each list protected by its own spinlock via
162 * the file_lock_lglock. Note that alterations to the list also require that
163 * the relevant i_lock is held.
160 */ 164 */
161static HLIST_HEAD(file_lock_list); 165DEFINE_STATIC_LGLOCK(file_lock_lglock);
162static DEFINE_SPINLOCK(file_lock_lock); 166static DEFINE_PER_CPU(struct hlist_head, file_lock_list);
163 167
164/* 168/*
165 * The blocked_hash is used to find POSIX lock loops for deadlock detection. 169 * The blocked_hash is used to find POSIX lock loops for deadlock detection.
@@ -506,20 +510,30 @@ static int posix_same_owner(struct file_lock *fl1, struct file_lock *fl2)
506 return fl1->fl_owner == fl2->fl_owner; 510 return fl1->fl_owner == fl2->fl_owner;
507} 511}
508 512
513/* Must be called with the i_lock held! */
509static inline void 514static inline void
510locks_insert_global_locks(struct file_lock *fl) 515locks_insert_global_locks(struct file_lock *fl)
511{ 516{
512 spin_lock(&file_lock_lock); 517 lg_local_lock(&file_lock_lglock);
513 hlist_add_head(&fl->fl_link, &file_lock_list); 518 fl->fl_link_cpu = smp_processor_id();
514 spin_unlock(&file_lock_lock); 519 hlist_add_head(&fl->fl_link, this_cpu_ptr(&file_lock_list));
520 lg_local_unlock(&file_lock_lglock);
515} 521}
516 522
523/* Must be called with the i_lock held! */
517static inline void 524static inline void
518locks_delete_global_locks(struct file_lock *fl) 525locks_delete_global_locks(struct file_lock *fl)
519{ 526{
520 spin_lock(&file_lock_lock); 527 /*
528 * Avoid taking lock if already unhashed. This is safe since this check
529 * is done while holding the i_lock, and new insertions into the list
530 * also require that it be held.
531 */
532 if (hlist_unhashed(&fl->fl_link))
533 return;
534 lg_local_lock_cpu(&file_lock_lglock, fl->fl_link_cpu);
521 hlist_del_init(&fl->fl_link); 535 hlist_del_init(&fl->fl_link);
522 spin_unlock(&file_lock_lock); 536 lg_local_unlock_cpu(&file_lock_lglock, fl->fl_link_cpu);
523} 537}
524 538
525static unsigned long 539static unsigned long
@@ -1454,7 +1468,7 @@ static int generic_add_lease(struct file *filp, long arg, struct file_lock **flp
1454 if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0)) 1468 if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0))
1455 goto out; 1469 goto out;
1456 if ((arg == F_WRLCK) 1470 if ((arg == F_WRLCK)
1457 && ((dentry->d_count > 1) 1471 && ((d_count(dentry) > 1)
1458 || (atomic_read(&inode->i_count) > 1))) 1472 || (atomic_read(&inode->i_count) > 1)))
1459 goto out; 1473 goto out;
1460 1474
@@ -2243,6 +2257,11 @@ EXPORT_SYMBOL_GPL(vfs_cancel_lock);
2243#include <linux/proc_fs.h> 2257#include <linux/proc_fs.h>
2244#include <linux/seq_file.h> 2258#include <linux/seq_file.h>
2245 2259
2260struct locks_iterator {
2261 int li_cpu;
2262 loff_t li_pos;
2263};
2264
2246static void lock_get_status(struct seq_file *f, struct file_lock *fl, 2265static void lock_get_status(struct seq_file *f, struct file_lock *fl,
2247 loff_t id, char *pfx) 2266 loff_t id, char *pfx)
2248{ 2267{
@@ -2316,39 +2335,41 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
2316 2335
2317static int locks_show(struct seq_file *f, void *v) 2336static int locks_show(struct seq_file *f, void *v)
2318{ 2337{
2338 struct locks_iterator *iter = f->private;
2319 struct file_lock *fl, *bfl; 2339 struct file_lock *fl, *bfl;
2320 2340
2321 fl = hlist_entry(v, struct file_lock, fl_link); 2341 fl = hlist_entry(v, struct file_lock, fl_link);
2322 2342
2323 lock_get_status(f, fl, *((loff_t *)f->private), ""); 2343 lock_get_status(f, fl, iter->li_pos, "");
2324 2344
2325 list_for_each_entry(bfl, &fl->fl_block, fl_block) 2345 list_for_each_entry(bfl, &fl->fl_block, fl_block)
2326 lock_get_status(f, bfl, *((loff_t *)f->private), " ->"); 2346 lock_get_status(f, bfl, iter->li_pos, " ->");
2327 2347
2328 return 0; 2348 return 0;
2329} 2349}
2330 2350
2331static void *locks_start(struct seq_file *f, loff_t *pos) 2351static void *locks_start(struct seq_file *f, loff_t *pos)
2332{ 2352{
2333 loff_t *p = f->private; 2353 struct locks_iterator *iter = f->private;
2334 2354
2335 spin_lock(&file_lock_lock); 2355 iter->li_pos = *pos + 1;
2356 lg_global_lock(&file_lock_lglock);
2336 spin_lock(&blocked_lock_lock); 2357 spin_lock(&blocked_lock_lock);
2337 *p = (*pos + 1); 2358 return seq_hlist_start_percpu(&file_lock_list, &iter->li_cpu, *pos);
2338 return seq_hlist_start(&file_lock_list, *pos);
2339} 2359}
2340 2360
2341static void *locks_next(struct seq_file *f, void *v, loff_t *pos) 2361static void *locks_next(struct seq_file *f, void *v, loff_t *pos)
2342{ 2362{
2343 loff_t *p = f->private; 2363 struct locks_iterator *iter = f->private;
2344 ++*p; 2364
2345 return seq_hlist_next(v, &file_lock_list, pos); 2365 ++iter->li_pos;
2366 return seq_hlist_next_percpu(v, &file_lock_list, &iter->li_cpu, pos);
2346} 2367}
2347 2368
2348static void locks_stop(struct seq_file *f, void *v) 2369static void locks_stop(struct seq_file *f, void *v)
2349{ 2370{
2350 spin_unlock(&blocked_lock_lock); 2371 spin_unlock(&blocked_lock_lock);
2351 spin_unlock(&file_lock_lock); 2372 lg_global_unlock(&file_lock_lglock);
2352} 2373}
2353 2374
2354static const struct seq_operations locks_seq_operations = { 2375static const struct seq_operations locks_seq_operations = {
@@ -2360,7 +2381,8 @@ static const struct seq_operations locks_seq_operations = {
2360 2381
2361static int locks_open(struct inode *inode, struct file *filp) 2382static int locks_open(struct inode *inode, struct file *filp)
2362{ 2383{
2363 return seq_open_private(filp, &locks_seq_operations, sizeof(loff_t)); 2384 return seq_open_private(filp, &locks_seq_operations,
2385 sizeof(struct locks_iterator));
2364} 2386}
2365 2387
2366static const struct file_operations proc_locks_operations = { 2388static const struct file_operations proc_locks_operations = {
@@ -2460,9 +2482,16 @@ EXPORT_SYMBOL(lock_may_write);
2460 2482
2461static int __init filelock_init(void) 2483static int __init filelock_init(void)
2462{ 2484{
2485 int i;
2486
2463 filelock_cache = kmem_cache_create("file_lock_cache", 2487 filelock_cache = kmem_cache_create("file_lock_cache",
2464 sizeof(struct file_lock), 0, SLAB_PANIC, NULL); 2488 sizeof(struct file_lock), 0, SLAB_PANIC, NULL);
2465 2489
2490 lg_lock_init(&file_lock_lglock, "file_lock_lglock");
2491
2492 for_each_possible_cpu(i)
2493 INIT_HLIST_HEAD(per_cpu_ptr(&file_lock_list, i));
2494
2466 return 0; 2495 return 0;
2467} 2496}
2468 2497
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 0765ad12c382..4659da67e7f6 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -403,18 +403,24 @@ static int ncp_parse_options(struct ncp_mount_data_kernel *data, char *options)
403 switch (optval) { 403 switch (optval) {
404 case 'u': 404 case 'u':
405 data->uid = make_kuid(current_user_ns(), optint); 405 data->uid = make_kuid(current_user_ns(), optint);
406 if (!uid_valid(data->uid)) 406 if (!uid_valid(data->uid)) {
407 ret = -EINVAL;
407 goto err; 408 goto err;
409 }
408 break; 410 break;
409 case 'g': 411 case 'g':
410 data->gid = make_kgid(current_user_ns(), optint); 412 data->gid = make_kgid(current_user_ns(), optint);
411 if (!gid_valid(data->gid)) 413 if (!gid_valid(data->gid)) {
414 ret = -EINVAL;
412 goto err; 415 goto err;
416 }
413 break; 417 break;
414 case 'o': 418 case 'o':
415 data->mounted_uid = make_kuid(current_user_ns(), optint); 419 data->mounted_uid = make_kuid(current_user_ns(), optint);
416 if (!uid_valid(data->mounted_uid)) 420 if (!uid_valid(data->mounted_uid)) {
421 ret = -EINVAL;
417 goto err; 422 goto err;
423 }
418 break; 424 break;
419 case 'm': 425 case 'm':
420 data->file_mode = optint; 426 data->file_mode = optint;
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index d7ed697133f0..c933bdfbcb1f 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1721,7 +1721,7 @@ int nfs_unlink(struct inode *dir, struct dentry *dentry)
1721 dir->i_ino, dentry->d_name.name); 1721 dir->i_ino, dentry->d_name.name);
1722 1722
1723 spin_lock(&dentry->d_lock); 1723 spin_lock(&dentry->d_lock);
1724 if (dentry->d_count > 1) { 1724 if (d_count(dentry) > 1) {
1725 spin_unlock(&dentry->d_lock); 1725 spin_unlock(&dentry->d_lock);
1726 /* Start asynchronous writeout of the inode */ 1726 /* Start asynchronous writeout of the inode */
1727 write_inode_now(dentry->d_inode, 0); 1727 write_inode_now(dentry->d_inode, 0);
@@ -1866,7 +1866,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1866 dfprintk(VFS, "NFS: rename(%s/%s -> %s/%s, ct=%d)\n", 1866 dfprintk(VFS, "NFS: rename(%s/%s -> %s/%s, ct=%d)\n",
1867 old_dentry->d_parent->d_name.name, old_dentry->d_name.name, 1867 old_dentry->d_parent->d_name.name, old_dentry->d_name.name,
1868 new_dentry->d_parent->d_name.name, new_dentry->d_name.name, 1868 new_dentry->d_parent->d_name.name, new_dentry->d_name.name,
1869 new_dentry->d_count); 1869 d_count(new_dentry));
1870 1870
1871 /* 1871 /*
1872 * For non-directories, check whether the target is busy and if so, 1872 * For non-directories, check whether the target is busy and if so,
@@ -1884,7 +1884,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1884 rehash = new_dentry; 1884 rehash = new_dentry;
1885 } 1885 }
1886 1886
1887 if (new_dentry->d_count > 2) { 1887 if (d_count(new_dentry) > 2) {
1888 int err; 1888 int err;
1889 1889
1890 /* copy the target dentry's name */ 1890 /* copy the target dentry's name */
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index 1f1f38f0c5d5..60395ad3a2e4 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -479,7 +479,7 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
479 479
480 dfprintk(VFS, "NFS: silly-rename(%s/%s, ct=%d)\n", 480 dfprintk(VFS, "NFS: silly-rename(%s/%s, ct=%d)\n",
481 dentry->d_parent->d_name.name, dentry->d_name.name, 481 dentry->d_parent->d_name.name, dentry->d_name.name,
482 dentry->d_count); 482 d_count(dentry));
483 nfs_inc_stats(dir, NFSIOS_SILLYRENAME); 483 nfs_inc_stats(dir, NFSIOS_SILLYRENAME);
484 484
485 /* 485 /*
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 1427de5ebf4d..af3ba0478cdf 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -996,7 +996,7 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno,
996 996
997static int nilfs_tree_was_touched(struct dentry *root_dentry) 997static int nilfs_tree_was_touched(struct dentry *root_dentry)
998{ 998{
999 return root_dentry->d_count > 1; 999 return d_count(root_dentry) > 1;
1000} 1000}
1001 1001
1002/** 1002/**
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 774c1eb7f1c9..3135c2525c76 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -921,3 +921,57 @@ struct hlist_node *seq_hlist_next_rcu(void *v,
921 return rcu_dereference(node->next); 921 return rcu_dereference(node->next);
922} 922}
923EXPORT_SYMBOL(seq_hlist_next_rcu); 923EXPORT_SYMBOL(seq_hlist_next_rcu);
924
925/**
926 * seq_hlist_start_precpu - start an iteration of a percpu hlist array
927 * @head: pointer to percpu array of struct hlist_heads
928 * @cpu: pointer to cpu "cursor"
929 * @pos: start position of sequence
930 *
931 * Called at seq_file->op->start().
932 */
933struct hlist_node *
934seq_hlist_start_percpu(struct hlist_head __percpu *head, int *cpu, loff_t pos)
935{
936 struct hlist_node *node;
937
938 for_each_possible_cpu(*cpu) {
939 hlist_for_each(node, per_cpu_ptr(head, *cpu)) {
940 if (pos-- == 0)
941 return node;
942 }
943 }
944 return NULL;
945}
946EXPORT_SYMBOL(seq_hlist_start_percpu);
947
948/**
949 * seq_hlist_next_percpu - move to the next position of the percpu hlist array
950 * @v: pointer to current hlist_node
951 * @head: pointer to percpu array of struct hlist_heads
952 * @cpu: pointer to cpu "cursor"
953 * @pos: start position of sequence
954 *
955 * Called at seq_file->op->next().
956 */
957struct hlist_node *
958seq_hlist_next_percpu(void *v, struct hlist_head __percpu *head,
959 int *cpu, loff_t *pos)
960{
961 struct hlist_node *node = v;
962
963 ++*pos;
964
965 if (node->next)
966 return node->next;
967
968 for (*cpu = cpumask_next(*cpu, cpu_possible_mask); *cpu < nr_cpu_ids;
969 *cpu = cpumask_next(*cpu, cpu_possible_mask)) {
970 struct hlist_head *bucket = per_cpu_ptr(head, *cpu);
971
972 if (!hlist_empty(bucket))
973 return bucket->first;
974 }
975 return NULL;
976}
977EXPORT_SYMBOL(seq_hlist_next_percpu);
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index f42dbe145479..3092df3614ae 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -324,6 +324,11 @@ static inline int __d_rcu_to_refcount(struct dentry *dentry, unsigned seq)
324 return ret; 324 return ret;
325} 325}
326 326
327static inline unsigned d_count(struct dentry *dentry)
328{
329 return dentry->d_count;
330}
331
327/* validate "insecure" dentry pointer */ 332/* validate "insecure" dentry pointer */
328extern int d_validate(struct dentry *, struct dentry *); 333extern int d_validate(struct dentry *, struct dentry *);
329 334
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 99be011e00de..834c9e5113d9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -954,6 +954,7 @@ struct file_lock {
954 unsigned int fl_flags; 954 unsigned int fl_flags;
955 unsigned char fl_type; 955 unsigned char fl_type;
956 unsigned int fl_pid; 956 unsigned int fl_pid;
957 int fl_link_cpu; /* what cpu's list is this on? */
957 struct pid *fl_nspid; 958 struct pid *fl_nspid;
958 wait_queue_head_t fl_wait; 959 wait_queue_head_t fl_wait;
959 struct file *fl_file; 960 struct file *fl_file;
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 2da29ac178fc..4e32edc8f506 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -173,4 +173,10 @@ extern struct hlist_node *seq_hlist_start_head_rcu(struct hlist_head *head,
173extern struct hlist_node *seq_hlist_next_rcu(void *v, 173extern struct hlist_node *seq_hlist_next_rcu(void *v,
174 struct hlist_head *head, 174 struct hlist_head *head,
175 loff_t *ppos); 175 loff_t *ppos);
176
177/* Helpers for iterating over per-cpu hlist_head-s in seq_files */
178extern struct hlist_node *seq_hlist_start_percpu(struct hlist_head __percpu *head, int *cpu, loff_t pos);
179
180extern struct hlist_node *seq_hlist_next_percpu(void *v, struct hlist_head __percpu *head, int *cpu, loff_t *pos);
181
176#endif 182#endif