Skip to content

Commit 3c2de27

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: - Preparations of parallel lookups (the remaining main obstacle is the need to move security_d_instantiate(); once that becomes safe, the rest will be a matter of rather short series local to fs/*.c - preadv2/pwritev2 series from Christoph - assorted fixes * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (32 commits) splice: handle zero nr_pages in splice_to_pipe() vfs: show_vfsstat: do not ignore errors from show_devname method dcache.c: new helper: __d_add() don't bother with __d_instantiate(dentry, NULL) untangle fsnotify_d_instantiate() a bit uninline d_add() replace d_add_unique() with saner primitive quota: use lookup_one_len_unlocked() cifs_get_root(): use lookup_one_len_unlocked() nfs_lookup: don't bother with d_instantiate(dentry, NULL) kill dentry_unhash() ceph_fill_trace(): don't bother with d_instantiate(dn, NULL) autofs4: don't bother with d_instantiate(dentry, NULL) in ->lookup() configfs: move d_rehash() into configfs_create() for regular files ceph: don't bother with d_rehash() in splice_dentry() namei: teach lookup_slow() to skip revalidate namei: massage lookup_slow() to be usable by lookup_one_len_unlocked() lookup_one_len_unlocked(): use lookup_dcache() namei: simplify invalidation logics in lookup_dcache() namei: change calling conventions for lookup_{fast,slow} and follow_managed() ...
2 parents 51b3eae + 8b23a8c commit 3c2de27

33 files changed

+488
-465
lines changed

arch/x86/entry/syscalls/syscall_32.tbl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,3 +384,5 @@
384384
375 i386 membarrier sys_membarrier
385385
376 i386 mlock2 sys_mlock2
386386
377 i386 copy_file_range sys_copy_file_range
387+
378 i386 preadv2 sys_preadv2
388+
379 i386 pwritev2 sys_pwritev2

arch/x86/entry/syscalls/syscall_64.tbl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@
333333
324 common membarrier sys_membarrier
334334
325 common mlock2 sys_mlock2
335335
326 common copy_file_range sys_copy_file_range
336+
327 64 preadv2 sys_preadv2
337+
328 64 pwritev2 sys_pwritev2
336338

337339
#
338340
# x32-specific system call numbers start at 512 to avoid cache impact

fs/autofs4/root.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,6 @@ static struct dentry *autofs4_lookup(struct inode *dir,
542542
ino->dentry = dentry;
543543

544544
autofs4_add_active(dentry);
545-
546-
d_instantiate(dentry, NULL);
547545
}
548546
return NULL;
549547
}

fs/cachefiles/daemon.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
162162
size_t buflen, loff_t *pos)
163163
{
164164
struct cachefiles_cache *cache = file->private_data;
165+
unsigned long long b_released;
166+
unsigned f_released;
165167
char buffer[256];
166168
int n;
167169

@@ -174,6 +176,8 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
174176
cachefiles_has_space(cache, 0, 0);
175177

176178
/* summarise */
179+
f_released = atomic_xchg(&cache->f_released, 0);
180+
b_released = atomic_long_xchg(&cache->b_released, 0);
177181
clear_bit(CACHEFILES_STATE_CHANGED, &cache->flags);
178182

179183
n = snprintf(buffer, sizeof(buffer),
@@ -183,15 +187,18 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
183187
" fstop=%llx"
184188
" brun=%llx"
185189
" bcull=%llx"
186-
" bstop=%llx",
190+
" bstop=%llx"
191+
" freleased=%x"
192+
" breleased=%llx",
187193
test_bit(CACHEFILES_CULLING, &cache->flags) ? '1' : '0',
188194
(unsigned long long) cache->frun,
189195
(unsigned long long) cache->fcull,
190196
(unsigned long long) cache->fstop,
191197
(unsigned long long) cache->brun,
192198
(unsigned long long) cache->bcull,
193-
(unsigned long long) cache->bstop
194-
);
199+
(unsigned long long) cache->bstop,
200+
f_released,
201+
b_released);
195202

196203
if (n > buflen)
197204
return -EMSGSIZE;

fs/cachefiles/interface.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,8 @@ static void cachefiles_drop_object(struct fscache_object *_object)
291291
}
292292

293293
/* note that the object is now inactive */
294-
if (test_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags)) {
295-
write_lock(&cache->active_lock);
296-
if (!test_and_clear_bit(CACHEFILES_OBJECT_ACTIVE,
297-
&object->flags))
298-
BUG();
299-
rb_erase(&object->active_node, &cache->active_nodes);
300-
wake_up_bit(&object->flags, CACHEFILES_OBJECT_ACTIVE);
301-
write_unlock(&cache->active_lock);
302-
}
294+
if (test_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags))
295+
cachefiles_mark_object_inactive(cache, object);
303296

304297
dput(object->dentry);
305298
object->dentry = NULL;

fs/cachefiles/internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ struct cachefiles_cache {
6666
struct rb_root active_nodes; /* active nodes (can't be culled) */
6767
rwlock_t active_lock; /* lock for active_nodes */
6868
atomic_t gravecounter; /* graveyard uniquifier */
69+
atomic_t f_released; /* number of objects released lately */
70+
atomic_long_t b_released; /* number of blocks released lately */
6971
unsigned frun_percent; /* when to stop culling (% files) */
7072
unsigned fcull_percent; /* when to start culling (% files) */
7173
unsigned fstop_percent; /* when to stop allocating (% files) */
@@ -157,6 +159,8 @@ extern char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type);
157159
/*
158160
* namei.c
159161
*/
162+
extern void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
163+
struct cachefiles_object *object);
160164
extern int cachefiles_delete_object(struct cachefiles_cache *cache,
161165
struct cachefiles_object *object);
162166
extern int cachefiles_walk_to_object(struct cachefiles_object *parent,

fs/cachefiles/namei.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,28 @@ static int cachefiles_mark_object_active(struct cachefiles_cache *cache,
257257
return -ETIMEDOUT;
258258
}
259259

260+
/*
261+
* Mark an object as being inactive.
262+
*/
263+
void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
264+
struct cachefiles_object *object)
265+
{
266+
write_lock(&cache->active_lock);
267+
rb_erase(&object->active_node, &cache->active_nodes);
268+
clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
269+
write_unlock(&cache->active_lock);
270+
271+
wake_up_bit(&object->flags, CACHEFILES_OBJECT_ACTIVE);
272+
273+
/* This object can now be culled, so we need to let the daemon know
274+
* that there is something it can remove if it needs to.
275+
*/
276+
atomic_long_add(d_backing_inode(object->dentry)->i_blocks,
277+
&cache->b_released);
278+
if (atomic_inc_return(&cache->f_released))
279+
cachefiles_state_changed(cache);
280+
}
281+
260282
/*
261283
* delete an object representation from the cache
262284
* - file backed objects are unlinked
@@ -684,11 +706,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
684706

685707
check_error:
686708
_debug("check error %d", ret);
687-
write_lock(&cache->active_lock);
688-
rb_erase(&object->active_node, &cache->active_nodes);
689-
clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
690-
wake_up_bit(&object->flags, CACHEFILES_OBJECT_ACTIVE);
691-
write_unlock(&cache->active_lock);
709+
cachefiles_mark_object_inactive(cache, object);
692710
release_dentry:
693711
dput(object->dentry);
694712
object->dentry = NULL;

fs/ceph/inode.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -977,13 +977,8 @@ static void update_dentry_lease(struct dentry *dentry,
977977
/*
978978
* splice a dentry to an inode.
979979
* caller must hold directory i_mutex for this to be safe.
980-
*
981-
* we will only rehash the resulting dentry if @prehash is
982-
* true; @prehash will be set to false (for the benefit of
983-
* the caller) if we fail.
984980
*/
985-
static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
986-
bool *prehash)
981+
static struct dentry *splice_dentry(struct dentry *dn, struct inode *in)
987982
{
988983
struct dentry *realdn;
989984

@@ -996,8 +991,6 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
996991
if (IS_ERR(realdn)) {
997992
pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n",
998993
PTR_ERR(realdn), dn, in, ceph_vinop(in));
999-
if (prehash)
1000-
*prehash = false; /* don't rehash on error */
1001994
dn = realdn; /* note realdn contains the error */
1002995
goto out;
1003996
} else if (realdn) {
@@ -1013,8 +1006,6 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
10131006
dout("dn %p attached to %p ino %llx.%llx\n",
10141007
dn, d_inode(dn), ceph_vinop(d_inode(dn)));
10151008
}
1016-
if ((!prehash || *prehash) && d_unhashed(dn))
1017-
d_rehash(dn);
10181009
out:
10191010
return dn;
10201011
}
@@ -1247,10 +1238,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
12471238
dout("d_delete %p\n", dn);
12481239
d_delete(dn);
12491240
} else {
1250-
dout("d_instantiate %p NULL\n", dn);
1251-
d_instantiate(dn, NULL);
12521241
if (have_lease && d_unhashed(dn))
1253-
d_rehash(dn);
1242+
d_add(dn, NULL);
12541243
update_dentry_lease(dn, rinfo->dlease,
12551244
session,
12561245
req->r_request_started);
@@ -1262,7 +1251,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
12621251
if (d_really_is_negative(dn)) {
12631252
ceph_dir_clear_ordered(dir);
12641253
ihold(in);
1265-
dn = splice_dentry(dn, in, &have_lease);
1254+
dn = splice_dentry(dn, in);
12661255
if (IS_ERR(dn)) {
12671256
err = PTR_ERR(dn);
12681257
goto done;
@@ -1292,7 +1281,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
12921281
dout(" linking snapped dir %p to dn %p\n", in, dn);
12931282
ceph_dir_clear_ordered(dir);
12941283
ihold(in);
1295-
dn = splice_dentry(dn, in, NULL);
1284+
dn = splice_dentry(dn, in);
12961285
if (IS_ERR(dn)) {
12971286
err = PTR_ERR(dn);
12981287
goto done;
@@ -1503,7 +1492,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
15031492
}
15041493

15051494
if (d_really_is_negative(dn)) {
1506-
struct dentry *realdn = splice_dentry(dn, in, NULL);
1495+
struct dentry *realdn = splice_dentry(dn, in);
15071496
if (IS_ERR(realdn)) {
15081497
err = PTR_ERR(realdn);
15091498
d_drop(dn);

fs/cifs/cifsfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
642642
while (*s && *s != sep)
643643
s++;
644644

645-
inode_lock(dir);
646-
child = lookup_one_len(p, dentry, s - p);
647-
inode_unlock(dir);
645+
child = lookup_one_len_unlocked(p, dentry, s - p);
648646
dput(dentry);
649647
dentry = child;
650648
} while (!IS_ERR(dentry));

fs/configfs/dir.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,9 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
432432
(sd->s_type & CONFIGFS_ITEM_BIN_ATTR) ?
433433
configfs_init_bin_file :
434434
configfs_init_file);
435-
if (error) {
435+
if (error)
436436
configfs_put(sd);
437-
return error;
438-
}
439-
440-
d_rehash(dentry);
441-
442-
return 0;
437+
return error;
443438
}
444439

445440
static struct dentry * configfs_lookup(struct inode *dir,

fs/configfs/inode.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,17 @@ int configfs_create(struct dentry * dentry, umode_t mode, void (*init)(struct in
201201
configfs_set_inode_lock_class(sd, inode);
202202

203203
init(inode);
204-
d_instantiate(dentry, inode);
205-
if (S_ISDIR(mode) || S_ISLNK(mode))
204+
if (S_ISDIR(mode) || S_ISLNK(mode)) {
205+
/*
206+
* ->symlink(), ->mkdir(), configfs_register_subsystem() or
207+
* create_default_group() - already hashed.
208+
*/
209+
d_instantiate(dentry, inode);
206210
dget(dentry); /* pin link and directory dentries in core */
211+
} else {
212+
/* ->lookup() */
213+
d_add(dentry, inode);
214+
}
207215
return error;
208216
}
209217

0 commit comments

Comments
 (0)