Skip to content

Commit d27fb65

Browse files
committed
Merge branch 'work.dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc dcache updates from Al Viro: "Most of this pile is putting name length into struct name_snapshot and making use of it. The beginning of this series ("ovl_lookup_real_one(): don't bother with strlen()") ought to have been split in two (separate switch of name_snapshot to struct qstr from overlayfs reaping the trivial benefits of that), but I wanted to avoid a rebase - by the time I'd spotted that it was (a) in -next and (b) close to 5.1-final ;-/" * 'work.dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: audit_compare_dname_path(): switch to const struct qstr * audit_update_watch(): switch to const struct qstr * inotify_handle_event(): don't bother with strlen() fsnotify: switch send_to_group() and ->handle_event to const struct qstr * fsnotify(): switch to passing const struct qstr * for file_name switch fsnotify_move() to passing const struct qstr * for old_name ovl_lookup_real_one(): don't bother with strlen() sysv: bury the broken "quietly truncate the long filenames" logics nsfs: unobfuscate unexport d_alloc_pseudo()
2 parents d3511f5 + 795d673 commit d27fb65

File tree

25 files changed

+62
-79
lines changed

25 files changed

+62
-79
lines changed

Documentation/filesystems/porting

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,3 +668,8 @@ in your dentry operations instead.
668668
DCACHE_RCUACCESS is gone; having an RCU delay on dentry freeing is the
669669
default. DCACHE_NORCU opts out, and only d_alloc_pseudo() has any
670670
business doing so.
671+
--
672+
[mandatory]
673+
d_alloc_pseudo() is internal-only; uses outside of alloc_file_pseudo() are
674+
very suspect (and won't work in modules). Such uses are very likely to
675+
be misspelled d_alloc_anon().

fs/dcache.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,25 +284,23 @@ static inline int dname_external(const struct dentry *dentry)
284284
void take_dentry_name_snapshot(struct name_snapshot *name, struct dentry *dentry)
285285
{
286286
spin_lock(&dentry->d_lock);
287+
name->name = dentry->d_name;
287288
if (unlikely(dname_external(dentry))) {
288-
struct external_name *p = external_name(dentry);
289-
atomic_inc(&p->u.count);
290-
spin_unlock(&dentry->d_lock);
291-
name->name = p->name;
289+
atomic_inc(&external_name(dentry)->u.count);
292290
} else {
293291
memcpy(name->inline_name, dentry->d_iname,
294292
dentry->d_name.len + 1);
295-
spin_unlock(&dentry->d_lock);
296-
name->name = name->inline_name;
293+
name->name.name = name->inline_name;
297294
}
295+
spin_unlock(&dentry->d_lock);
298296
}
299297
EXPORT_SYMBOL(take_dentry_name_snapshot);
300298

301299
void release_dentry_name_snapshot(struct name_snapshot *name)
302300
{
303-
if (unlikely(name->name != name->inline_name)) {
301+
if (unlikely(name->name.name != name->inline_name)) {
304302
struct external_name *p;
305-
p = container_of(name->name, struct external_name, name[0]);
303+
p = container_of(name->name.name, struct external_name, name[0]);
306304
if (unlikely(atomic_dec_and_test(&p->u.count)))
307305
kfree_rcu(p, u.head);
308306
}
@@ -1742,6 +1740,9 @@ struct dentry *d_alloc_cursor(struct dentry * parent)
17421740
* never be anyone's children or parents. Unlike all other
17431741
* dentries, these will not have RCU delay between dropping the
17441742
* last reference and freeing them.
1743+
*
1744+
* The only user is alloc_file_pseudo() and that's what should
1745+
* be considered a public interface. Don't use directly.
17451746
*/
17461747
struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name)
17471748
{
@@ -1750,7 +1751,6 @@ struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name)
17501751
dentry->d_flags |= DCACHE_NORCU;
17511752
return dentry;
17521753
}
1753-
EXPORT_SYMBOL(d_alloc_pseudo);
17541754

17551755
struct dentry *d_alloc_name(struct dentry *parent, const char *name)
17561756
{

fs/debugfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
818818
goto exit;
819819
}
820820
d_move(old_dentry, dentry);
821-
fsnotify_move(d_inode(old_dir), d_inode(new_dir), old_name.name,
821+
fsnotify_move(d_inode(old_dir), d_inode(new_dir), &old_name.name,
822822
d_is_dir(old_dentry),
823823
NULL, old_dentry);
824824
release_dentry_name_snapshot(&old_name);

fs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ extern struct dentry *__d_alloc(struct super_block *, const struct qstr *);
155155
extern int d_set_mounted(struct dentry *dentry);
156156
extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
157157
extern struct dentry *d_alloc_cursor(struct dentry *);
158+
extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
158159

159160
/*
160161
* read_write.c

fs/kernfs/file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ static void kernfs_notify_workfn(struct work_struct *work)
885885
list_for_each_entry(info, &kernfs_root(kn)->supers, node) {
886886
struct kernfs_node *parent;
887887
struct inode *inode;
888+
struct qstr name;
888889

889890
/*
890891
* We want fsnotify_modify() on @kn but as the
@@ -896,22 +897,23 @@ static void kernfs_notify_workfn(struct work_struct *work)
896897
if (!inode)
897898
continue;
898899

900+
name = (struct qstr)QSTR_INIT(kn->name, strlen(kn->name));
899901
parent = kernfs_get_parent(kn);
900902
if (parent) {
901903
struct inode *p_inode;
902904

903905
p_inode = ilookup(info->sb, parent->id.ino);
904906
if (p_inode) {
905907
fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD,
906-
inode, FSNOTIFY_EVENT_INODE, kn->name, 0);
908+
inode, FSNOTIFY_EVENT_INODE, &name, 0);
907909
iput(p_inode);
908910
}
909911

910912
kernfs_put(parent);
911913
}
912914

913915
fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE,
914-
kn->name, 0);
916+
&name, 0);
915917
iput(inode);
916918
}
917919

fs/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4498,10 +4498,10 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
44984498
inode_unlock(target);
44994499
dput(new_dentry);
45004500
if (!error) {
4501-
fsnotify_move(old_dir, new_dir, old_name.name, is_dir,
4501+
fsnotify_move(old_dir, new_dir, &old_name.name, is_dir,
45024502
!(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry);
45034503
if (flags & RENAME_EXCHANGE) {
4504-
fsnotify_move(new_dir, old_dir, old_dentry->d_name.name,
4504+
fsnotify_move(new_dir, old_dir, &old_dentry->d_name,
45054505
new_is_dir, NULL, new_dentry);
45064506
}
45074507
}

fs/notify/dnotify/dnotify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark *fsn_mark)
8181
static int dnotify_handle_event(struct fsnotify_group *group,
8282
struct inode *inode,
8383
u32 mask, const void *data, int data_type,
84-
const unsigned char *file_name, u32 cookie,
84+
const struct qstr *file_name, u32 cookie,
8585
struct fsnotify_iter_info *iter_info)
8686
{
8787
struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);

fs/notify/fanotify/fanotify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static __kernel_fsid_t fanotify_get_fsid(struct fsnotify_iter_info *iter_info)
367367
static int fanotify_handle_event(struct fsnotify_group *group,
368368
struct inode *inode,
369369
u32 mask, const void *data, int data_type,
370-
const unsigned char *file_name, u32 cookie,
370+
const struct qstr *file_name, u32 cookie,
371371
struct fsnotify_iter_info *iter_info)
372372
{
373373
int ret = 0;

fs/notify/fsnotify.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
179179
take_dentry_name_snapshot(&name, dentry);
180180
if (path)
181181
ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
182-
name.name, 0);
182+
&name.name, 0);
183183
else
184184
ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
185-
name.name, 0);
185+
&name.name, 0);
186186
release_dentry_name_snapshot(&name);
187187
}
188188

@@ -195,7 +195,7 @@ EXPORT_SYMBOL_GPL(__fsnotify_parent);
195195
static int send_to_group(struct inode *to_tell,
196196
__u32 mask, const void *data,
197197
int data_is, u32 cookie,
198-
const unsigned char *file_name,
198+
const struct qstr *file_name,
199199
struct fsnotify_iter_info *iter_info)
200200
{
201201
struct fsnotify_group *group = NULL;
@@ -325,7 +325,7 @@ static void fsnotify_iter_next(struct fsnotify_iter_info *iter_info)
325325
* notification event in whatever means they feel necessary.
326326
*/
327327
int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
328-
const unsigned char *file_name, u32 cookie)
328+
const struct qstr *file_name, u32 cookie)
329329
{
330330
struct fsnotify_iter_info iter_info = {};
331331
struct super_block *sb = to_tell->i_sb;

fs/notify/inotify/inotify.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
2727
extern int inotify_handle_event(struct fsnotify_group *group,
2828
struct inode *inode,
2929
u32 mask, const void *data, int data_type,
30-
const unsigned char *file_name, u32 cookie,
30+
const struct qstr *file_name, u32 cookie,
3131
struct fsnotify_iter_info *iter_info);
3232

3333
extern const struct fsnotify_ops inotify_fsnotify_ops;

0 commit comments

Comments
 (0)