Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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()
  ...
  • Loading branch information
torvalds committed Mar 20, 2016
2 parents 51b3eae + 8b23a8c commit 3c2de27
Show file tree
Hide file tree
Showing 33 changed files with 488 additions and 465 deletions.
2 changes: 2 additions & 0 deletions arch/x86/entry/syscalls/syscall_32.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,5 @@
375 i386 membarrier sys_membarrier
376 i386 mlock2 sys_mlock2
377 i386 copy_file_range sys_copy_file_range
378 i386 preadv2 sys_preadv2
379 i386 pwritev2 sys_pwritev2
2 changes: 2 additions & 0 deletions arch/x86/entry/syscalls/syscall_64.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@
324 common membarrier sys_membarrier
325 common mlock2 sys_mlock2
326 common copy_file_range sys_copy_file_range
327 64 preadv2 sys_preadv2
328 64 pwritev2 sys_pwritev2

#
# x32-specific system call numbers start at 512 to avoid cache impact
Expand Down
2 changes: 0 additions & 2 deletions fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,6 @@ static struct dentry *autofs4_lookup(struct inode *dir,
ino->dentry = dentry;

autofs4_add_active(dentry);

d_instantiate(dentry, NULL);
}
return NULL;
}
Expand Down
13 changes: 10 additions & 3 deletions fs/cachefiles/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
size_t buflen, loff_t *pos)
{
struct cachefiles_cache *cache = file->private_data;
unsigned long long b_released;
unsigned f_released;
char buffer[256];
int n;

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

/* summarise */
f_released = atomic_xchg(&cache->f_released, 0);
b_released = atomic_long_xchg(&cache->b_released, 0);
clear_bit(CACHEFILES_STATE_CHANGED, &cache->flags);

n = snprintf(buffer, sizeof(buffer),
Expand All @@ -183,15 +187,18 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
" fstop=%llx"
" brun=%llx"
" bcull=%llx"
" bstop=%llx",
" bstop=%llx"
" freleased=%x"
" breleased=%llx",
test_bit(CACHEFILES_CULLING, &cache->flags) ? '1' : '0',
(unsigned long long) cache->frun,
(unsigned long long) cache->fcull,
(unsigned long long) cache->fstop,
(unsigned long long) cache->brun,
(unsigned long long) cache->bcull,
(unsigned long long) cache->bstop
);
(unsigned long long) cache->bstop,
f_released,
b_released);

if (n > buflen)
return -EMSGSIZE;
Expand Down
11 changes: 2 additions & 9 deletions fs/cachefiles/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,8 @@ static void cachefiles_drop_object(struct fscache_object *_object)
}

/* note that the object is now inactive */
if (test_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags)) {
write_lock(&cache->active_lock);
if (!test_and_clear_bit(CACHEFILES_OBJECT_ACTIVE,
&object->flags))
BUG();
rb_erase(&object->active_node, &cache->active_nodes);
wake_up_bit(&object->flags, CACHEFILES_OBJECT_ACTIVE);
write_unlock(&cache->active_lock);
}
if (test_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags))
cachefiles_mark_object_inactive(cache, object);

dput(object->dentry);
object->dentry = NULL;
Expand Down
4 changes: 4 additions & 0 deletions fs/cachefiles/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ struct cachefiles_cache {
struct rb_root active_nodes; /* active nodes (can't be culled) */
rwlock_t active_lock; /* lock for active_nodes */
atomic_t gravecounter; /* graveyard uniquifier */
atomic_t f_released; /* number of objects released lately */
atomic_long_t b_released; /* number of blocks released lately */
unsigned frun_percent; /* when to stop culling (% files) */
unsigned fcull_percent; /* when to start culling (% files) */
unsigned fstop_percent; /* when to stop allocating (% files) */
Expand Down Expand Up @@ -157,6 +159,8 @@ extern char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type);
/*
* namei.c
*/
extern void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
struct cachefiles_object *object);
extern int cachefiles_delete_object(struct cachefiles_cache *cache,
struct cachefiles_object *object);
extern int cachefiles_walk_to_object(struct cachefiles_object *parent,
Expand Down
28 changes: 23 additions & 5 deletions fs/cachefiles/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,28 @@ static int cachefiles_mark_object_active(struct cachefiles_cache *cache,
return -ETIMEDOUT;
}

/*
* Mark an object as being inactive.
*/
void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
struct cachefiles_object *object)
{
write_lock(&cache->active_lock);
rb_erase(&object->active_node, &cache->active_nodes);
clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
write_unlock(&cache->active_lock);

wake_up_bit(&object->flags, CACHEFILES_OBJECT_ACTIVE);

/* This object can now be culled, so we need to let the daemon know
* that there is something it can remove if it needs to.
*/
atomic_long_add(d_backing_inode(object->dentry)->i_blocks,
&cache->b_released);
if (atomic_inc_return(&cache->f_released))
cachefiles_state_changed(cache);
}

/*
* delete an object representation from the cache
* - file backed objects are unlinked
Expand Down Expand Up @@ -684,11 +706,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,

check_error:
_debug("check error %d", ret);
write_lock(&cache->active_lock);
rb_erase(&object->active_node, &cache->active_nodes);
clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
wake_up_bit(&object->flags, CACHEFILES_OBJECT_ACTIVE);
write_unlock(&cache->active_lock);
cachefiles_mark_object_inactive(cache, object);
release_dentry:
dput(object->dentry);
object->dentry = NULL;
Expand Down
21 changes: 5 additions & 16 deletions fs/ceph/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,13 +977,8 @@ static void update_dentry_lease(struct dentry *dentry,
/*
* splice a dentry to an inode.
* caller must hold directory i_mutex for this to be safe.
*
* we will only rehash the resulting dentry if @prehash is
* true; @prehash will be set to false (for the benefit of
* the caller) if we fail.
*/
static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
bool *prehash)
static struct dentry *splice_dentry(struct dentry *dn, struct inode *in)
{
struct dentry *realdn;

Expand All @@ -996,8 +991,6 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
if (IS_ERR(realdn)) {
pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n",
PTR_ERR(realdn), dn, in, ceph_vinop(in));
if (prehash)
*prehash = false; /* don't rehash on error */
dn = realdn; /* note realdn contains the error */
goto out;
} else if (realdn) {
Expand All @@ -1013,8 +1006,6 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
dout("dn %p attached to %p ino %llx.%llx\n",
dn, d_inode(dn), ceph_vinop(d_inode(dn)));
}
if ((!prehash || *prehash) && d_unhashed(dn))
d_rehash(dn);
out:
return dn;
}
Expand Down Expand Up @@ -1247,10 +1238,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
dout("d_delete %p\n", dn);
d_delete(dn);
} else {
dout("d_instantiate %p NULL\n", dn);
d_instantiate(dn, NULL);
if (have_lease && d_unhashed(dn))
d_rehash(dn);
d_add(dn, NULL);
update_dentry_lease(dn, rinfo->dlease,
session,
req->r_request_started);
Expand All @@ -1262,7 +1251,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
if (d_really_is_negative(dn)) {
ceph_dir_clear_ordered(dir);
ihold(in);
dn = splice_dentry(dn, in, &have_lease);
dn = splice_dentry(dn, in);
if (IS_ERR(dn)) {
err = PTR_ERR(dn);
goto done;
Expand Down Expand Up @@ -1292,7 +1281,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
dout(" linking snapped dir %p to dn %p\n", in, dn);
ceph_dir_clear_ordered(dir);
ihold(in);
dn = splice_dentry(dn, in, NULL);
dn = splice_dentry(dn, in);
if (IS_ERR(dn)) {
err = PTR_ERR(dn);
goto done;
Expand Down Expand Up @@ -1503,7 +1492,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
}

if (d_really_is_negative(dn)) {
struct dentry *realdn = splice_dentry(dn, in, NULL);
struct dentry *realdn = splice_dentry(dn, in);
if (IS_ERR(realdn)) {
err = PTR_ERR(realdn);
d_drop(dn);
Expand Down
4 changes: 1 addition & 3 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
while (*s && *s != sep)
s++;

inode_lock(dir);
child = lookup_one_len(p, dentry, s - p);
inode_unlock(dir);
child = lookup_one_len_unlocked(p, dentry, s - p);
dput(dentry);
dentry = child;
} while (!IS_ERR(dentry));
Expand Down
9 changes: 2 additions & 7 deletions fs/configfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,9 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
(sd->s_type & CONFIGFS_ITEM_BIN_ATTR) ?
configfs_init_bin_file :
configfs_init_file);
if (error) {
if (error)
configfs_put(sd);
return error;
}

d_rehash(dentry);

return 0;
return error;
}

static struct dentry * configfs_lookup(struct inode *dir,
Expand Down
12 changes: 10 additions & 2 deletions fs/configfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,17 @@ int configfs_create(struct dentry * dentry, umode_t mode, void (*init)(struct in
configfs_set_inode_lock_class(sd, inode);

init(inode);
d_instantiate(dentry, inode);
if (S_ISDIR(mode) || S_ISLNK(mode))
if (S_ISDIR(mode) || S_ISLNK(mode)) {
/*
* ->symlink(), ->mkdir(), configfs_register_subsystem() or
* create_default_group() - already hashed.
*/
d_instantiate(dentry, inode);
dget(dentry); /* pin link and directory dentries in core */
} else {
/* ->lookup() */
d_add(dentry, inode);
}
return error;
}

Expand Down
Loading

0 comments on commit 3c2de27

Please sign in to comment.