Skip to content

Commit

Permalink
Merge remote-tracking branch 'ovl/for-viro' into for-linus
Browse files Browse the repository at this point in the history
Overlayfs-related series from Miklos and Amir
  • Loading branch information
Al Viro committed Mar 2, 2017
2 parents f6c99aa + 0eb8af4 commit 653a774
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 134 deletions.
4 changes: 2 additions & 2 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,9 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
cmd->iocb.ki_flags = IOCB_DIRECT;

if (rw == WRITE)
ret = file->f_op->write_iter(&cmd->iocb, &iter);
ret = call_write_iter(file, &cmd->iocb, &iter);
else
ret = file->f_op->read_iter(&cmd->iocb, &iter);
ret = call_read_iter(file, &cmd->iocb, &iter);

if (ret != -EIOCBQUEUED)
cmd->iocb.ki_complete(&cmd->iocb, ret, 0);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/i915_gem_dmabuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *
if (!obj->base.filp)
return -ENODEV;

ret = obj->base.filp->f_op->mmap(obj->base.filp, vma);
ret = call_mmap(obj->base.filp, vma);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/vgem/vgem_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static int vgem_prime_mmap(struct drm_gem_object *obj,
if (!obj->filp)
return -ENODEV;

ret = obj->filp->f_op->mmap(obj->filp, vma);
ret = call_mmap(obj->filp, vma);
if (ret)
return ret;

Expand Down
4 changes: 2 additions & 2 deletions fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ static ssize_t aio_read(struct kiocb *req, struct iocb *iocb, bool vectored,
return ret;
ret = rw_verify_area(READ, file, &req->ki_pos, iov_iter_count(&iter));
if (!ret)
ret = aio_ret(req, file->f_op->read_iter(req, &iter));
ret = aio_ret(req, call_read_iter(file, req, &iter));
kfree(iovec);
return ret;
}
Expand All @@ -1520,7 +1520,7 @@ static ssize_t aio_write(struct kiocb *req, struct iocb *iocb, bool vectored,
if (!ret) {
req->ki_flags |= IOCB_WRITE;
file_start_write(file);
ret = aio_ret(req, file->f_op->write_iter(req, &iter));
ret = aio_ret(req, call_write_iter(file, req, &iter));
/*
* We release freeze protection in aio_complete(). Fool lockdep
* by telling it the lock got released so that it doesn't
Expand Down
2 changes: 1 addition & 1 deletion fs/coda/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
cfi->cfi_mapcount++;
spin_unlock(&cii->c_lock);

return host_file->f_op->mmap(host_file, vma);
return call_mmap(host_file, vma);
}

int coda_open(struct inode *coda_inode, struct file *coda_file)
Expand Down
68 changes: 43 additions & 25 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -3363,39 +3363,63 @@ static int do_last(struct nameidata *nd,
return error;
}

struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode, int open_flag)
{
static const struct qstr name = QSTR_INIT("/", 1);
struct dentry *child = NULL;
struct inode *dir = dentry->d_inode;
struct inode *inode;
int error;

/* we want directory to be writable */
error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
if (error)
goto out_err;
error = -EOPNOTSUPP;
if (!dir->i_op->tmpfile)
goto out_err;
error = -ENOMEM;
child = d_alloc(dentry, &name);
if (unlikely(!child))
goto out_err;
error = dir->i_op->tmpfile(dir, child, mode);
if (error)
goto out_err;
error = -ENOENT;
inode = child->d_inode;
if (unlikely(!inode))
goto out_err;
if (!(open_flag & O_EXCL)) {
spin_lock(&inode->i_lock);
inode->i_state |= I_LINKABLE;
spin_unlock(&inode->i_lock);
}
return child;

out_err:
dput(child);
return ERR_PTR(error);
}
EXPORT_SYMBOL(vfs_tmpfile);

static int do_tmpfile(struct nameidata *nd, unsigned flags,
const struct open_flags *op,
struct file *file, int *opened)
{
static const struct qstr name = QSTR_INIT("/", 1);
struct dentry *child;
struct inode *dir;
struct path path;
int error = path_lookupat(nd, flags | LOOKUP_DIRECTORY, &path);
if (unlikely(error))
return error;
error = mnt_want_write(path.mnt);
if (unlikely(error))
goto out;
dir = path.dentry->d_inode;
/* we want directory to be writable */
error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
if (error)
goto out2;
if (!dir->i_op->tmpfile) {
error = -EOPNOTSUPP;
goto out2;
}
child = d_alloc(path.dentry, &name);
if (unlikely(!child)) {
error = -ENOMEM;
child = vfs_tmpfile(path.dentry, op->mode, op->open_flag);
error = PTR_ERR(child);
if (unlikely(IS_ERR(child)))
goto out2;
}
dput(path.dentry);
path.dentry = child;
error = dir->i_op->tmpfile(dir, child, op->mode);
if (error)
goto out2;
audit_inode(nd->name, child, 0);
/* Don't check for other permissions, the inode was just created */
error = may_open(&path, 0, op->open_flag);
Expand All @@ -3406,14 +3430,8 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
if (error)
goto out2;
error = open_check_o_direct(file);
if (error) {
if (error)
fput(file);
} else if (!(op->open_flag & O_EXCL)) {
struct inode *inode = file_inode(file);
spin_lock(&inode->i_lock);
inode->i_state |= I_LINKABLE;
spin_unlock(&inode->i_lock);
}
out2:
mnt_drop_write(path.mnt);
out:
Expand Down
14 changes: 6 additions & 8 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,10 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
if (S_ISFIFO(inode->i_mode))
return -ESPIPE;

/*
* Let individual file system decide if it supports preallocation
* for directories or not.
*/
if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
!S_ISBLK(inode->i_mode))
if (S_ISDIR(inode->i_mode))
return -EISDIR;

if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
return -ENODEV;

/* Check for wrap through zero too */
Expand All @@ -316,7 +314,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
if (!file->f_op->fallocate)
return -EOPNOTSUPP;

sb_start_write(inode->i_sb);
file_start_write(file);
ret = file->f_op->fallocate(file, mode, offset, len);

/*
Expand All @@ -329,7 +327,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
if (ret == 0)
fsnotify_modify(file);

sb_end_write(inode->i_sb);
file_end_write(file);
return ret;
}
EXPORT_SYMBOL_GPL(vfs_fallocate);
Expand Down
Loading

0 comments on commit 653a774

Please sign in to comment.