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-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
  remove detritus left by "mm: make read_cache_page synchronous"
  fix fs/sysv s_dirt handling
  fat: convert to use the new truncate convention.
  ext2: convert to use the new truncate convention.
  tmpfs: convert to use the new truncate convention
  fs: convert simple fs to new truncate
  kill spurious reference to vmtruncate
  fs: introduce new truncate sequence
  fs/super: fix kernel-doc warning
  fs/minix: bugfix, number of indirect block ptrs per block depends on block size
  rename the generic fsync implementations
  drop unused dentry argument to ->fsync
  fs: Add missing mutex_unlock
  Fix racy use of anon_inode_getfd() in perf_event.c
  get rid of the magic around f_count in aio
  VFS: fix recent breakage of FS_REVAL_DOT
  Revert "anon_inode: set S_IFREG on the anon_inode"
  • Loading branch information
Linus Torvalds committed May 28, 2010
2 parents aa36c7b + 49837a8 commit 89ad6a6
Show file tree
Hide file tree
Showing 112 changed files with 782 additions and 415 deletions.
2 changes: 1 addition & 1 deletion Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ prototypes:
int (*open) (struct inode *, struct file *);
int (*flush) (struct file *);
int (*release) (struct inode *, struct file *);
int (*fsync) (struct file *, struct dentry *, int datasync);
int (*fsync) (struct file *, int datasync);
int (*aio_fsync) (struct kiocb *, int datasync);
int (*fasync) (int, struct file *, int);
int (*lock) (struct file *, int, struct file_lock *);
Expand Down
9 changes: 7 additions & 2 deletions Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,16 @@ otherwise noted.
started might not be in the page cache at the end of the
walk).

truncate: called by the VFS to change the size of a file. The
truncate: Deprecated. This will not be called if ->setsize is defined.
Called by the VFS to change the size of a file. The
i_size field of the inode is set to the desired size by the
VFS before this method is called. This method is called by
the truncate(2) system call and related functionality.

Note: ->truncate and vmtruncate are deprecated. Do not add new
instances/calls of these. Filesystems should be converted to do their
truncate sequence via ->setattr().

permission: called by the VFS to check for access rights on a POSIX-like
filesystem.

Expand Down Expand Up @@ -729,7 +734,7 @@ struct file_operations {
int (*open) (struct inode *, struct file *);
int (*flush) (struct file *);
int (*release) (struct inode *, struct file *);
int (*fsync) (struct file *, struct dentry *, int datasync);
int (*fsync) (struct file *, int datasync);
int (*aio_fsync) (struct kiocb *, int datasync);
int (*fasync) (int, struct file *, int);
int (*lock) (struct file *, int, struct file_lock *);
Expand Down
3 changes: 1 addition & 2 deletions arch/powerpc/platforms/cell/spufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1849,8 +1849,7 @@ static int spufs_mfc_flush(struct file *file, fl_owner_t id)
return ret;
}

static int spufs_mfc_fsync(struct file *file, struct dentry *dentry,
int datasync)
static int spufs_mfc_fsync(struct file *file, int datasync)
{
return spufs_mfc_flush(file, NULL);
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const struct file_operations spufs_context_fops = {
.llseek = dcache_dir_lseek,
.read = generic_read_dir,
.readdir = dcache_readdir,
.fsync = simple_sync_file,
.fsync = noop_fsync,
};
EXPORT_SYMBOL_GPL(spufs_context_fops);

Expand Down
3 changes: 1 addition & 2 deletions drivers/char/ps3flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ static int ps3flash_flush(struct file *file, fl_owner_t id)
return ps3flash_writeback(ps3flash_dev);
}

static int ps3flash_fsync(struct file *file, struct dentry *dentry,
int datasync)
static int ps3flash_fsync(struct file *file, int datasync)
{
return ps3flash_writeback(ps3flash_dev);
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/mtd/ubi/cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin)
return new_offset;
}

static int vol_cdev_fsync(struct file *file, struct dentry *dentry,
int datasync)
static int vol_cdev_fsync(struct file *file, int datasync)
{
struct ubi_volume_desc *desc = file->private_data;
struct ubi_device *ubi = desc->vol->ubi;
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/pohmelfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ static struct inode *pohmelfs_alloc_inode(struct super_block *sb)
/*
* We want fsync() to work on POHMELFS.
*/
static int pohmelfs_fsync(struct file *file, struct dentry *dentry, int datasync)
static int pohmelfs_fsync(struct file *file, int datasync)
{
struct inode *inode = file->f_mapping->host;
struct writeback_control wbc = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
}

static int
printer_fsync(struct file *fd, struct dentry *dentry, int datasync)
printer_fsync(struct file *fd, int datasync)
{
struct printer_dev *dev = fd->private_data;
unsigned long flags;
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fb_defio.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static int fb_deferred_io_fault(struct vm_area_struct *vma,
return 0;
}

int fb_deferred_io_fsync(struct file *file, struct dentry *dentry, int datasync)
int fb_deferred_io_fsync(struct file *file, int datasync)
{
struct fb_info *info = file->private_data;

Expand Down
6 changes: 2 additions & 4 deletions fs/9p/vfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,13 @@ v9fs_file_write(struct file *filp, const char __user * data,
return total;
}

static int v9fs_file_fsync(struct file *filp, struct dentry *dentry,
int datasync)
static int v9fs_file_fsync(struct file *filp, int datasync)
{
struct p9_fid *fid;
struct p9_wstat wstat;
int retval;

P9_DPRINTK(P9_DEBUG_VFS, "filp %p dentry %p datasync %x\n", filp,
dentry, datasync);
P9_DPRINTK(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);

fid = filp->private_data;
v9fs_blank_wstat(&wstat);
Expand Down
2 changes: 1 addition & 1 deletion fs/adfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const struct file_operations adfs_dir_operations = {
.read = generic_read_dir,
.llseek = generic_file_llseek,
.readdir = adfs_readdir,
.fsync = simple_fsync,
.fsync = generic_file_fsync,
};

static int
Expand Down
2 changes: 1 addition & 1 deletion fs/adfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const struct file_operations adfs_file_operations = {
.read = do_sync_read,
.aio_read = generic_file_aio_read,
.mmap = generic_file_mmap,
.fsync = simple_fsync,
.fsync = generic_file_fsync,
.write = do_sync_write,
.aio_write = generic_file_aio_write,
.splice_read = generic_file_splice_read,
Expand Down
3 changes: 2 additions & 1 deletion fs/adfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,9 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
if (error)
goto out;

/* XXX: this is missing some actual on-disk truncation.. */
if (ia_valid & ATTR_SIZE)
error = vmtruncate(inode, attr->ia_size);
error = simple_setsize(inode, attr->ia_size);

if (error)
goto out;
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/affs.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ extern int affs_add_entry(struct inode *dir, struct inode *inode, struct dent

void affs_free_prealloc(struct inode *inode);
extern void affs_truncate(struct inode *);
int affs_file_fsync(struct file *, struct dentry *, int);
int affs_file_fsync(struct file *, int);

/* dir.c */

Expand Down
4 changes: 2 additions & 2 deletions fs/affs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,9 +916,9 @@ affs_truncate(struct inode *inode)
affs_free_prealloc(inode);
}

int affs_file_fsync(struct file *filp, struct dentry *dentry, int datasync)
int affs_file_fsync(struct file *filp, int datasync)
{
struct inode * inode = dentry->d_inode;
struct inode *inode = filp->f_mapping->host;
int ret, err;

ret = write_inode_now(inode, 0);
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *);
extern ssize_t afs_file_write(struct kiocb *, const struct iovec *,
unsigned long, loff_t);
extern int afs_writeback_all(struct afs_vnode *);
extern int afs_fsync(struct file *, struct dentry *, int);
extern int afs_fsync(struct file *, int);


/*****************************************************************************/
Expand Down
3 changes: 2 additions & 1 deletion fs/afs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,9 @@ int afs_writeback_all(struct afs_vnode *vnode)
* - the return status from this call provides a reliable indication of
* whether any write errors occurred for this process.
*/
int afs_fsync(struct file *file, struct dentry *dentry, int datasync)
int afs_fsync(struct file *file, int datasync)
{
struct dentry *dentry = file->f_path.dentry;
struct afs_writeback *wb, *xwb;
struct afs_vnode *vnode = AFS_FS_I(dentry->d_inode);
int ret;
Expand Down
6 changes: 3 additions & 3 deletions fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static void aio_fput_routine(struct work_struct *data)

/* Complete the fput(s) */
if (req->ki_filp != NULL)
__fput(req->ki_filp);
fput(req->ki_filp);

/* Link the iocb into the context's free list */
spin_lock_irq(&ctx->ctx_lock);
Expand Down Expand Up @@ -560,11 +560,11 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)

/*
* Try to optimize the aio and eventfd file* puts, by avoiding to
* schedule work in case it is not __fput() time. In normal cases,
* schedule work in case it is not final fput() time. In normal cases,
* we would not be holding the last reference to the file*, so
* this function will be executed w/out any aio kthread wakeup.
*/
if (unlikely(atomic_long_dec_and_test(&req->ki_filp->f_count))) {
if (unlikely(!fput_atomic(req->ki_filp))) {
get_ioctx(ctx);
spin_lock(&fput_lock);
list_add(&req->ki_list, &fput_head);
Expand Down
2 changes: 1 addition & 1 deletion fs/anon_inodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static struct inode *anon_inode_mkinode(void)
* that it already _is_ on the dirty list.
*/
inode->i_state = I_DIRTY;
inode->i_mode = S_IFREG | S_IRUSR | S_IWUSR;
inode->i_mode = S_IRUSR | S_IWUSR;
inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid();
inode->i_flags |= S_PRIVATE;
Expand Down
50 changes: 40 additions & 10 deletions fs/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ EXPORT_SYMBOL(inode_change_ok);
* @offset: the new size to assign to the inode
* @Returns: 0 on success, -ve errno on failure
*
* inode_newsize_ok must be called with i_mutex held.
*
* inode_newsize_ok will check filesystem limits and ulimits to check that the
* new inode size is within limits. inode_newsize_ok will also send SIGXFSZ
* when necessary. Caller must not proceed with inode size change if failure is
* returned. @inode must be a file (not directory), with appropriate
* permissions to allow truncate (inode_newsize_ok does NOT check these
* conditions).
*
* inode_newsize_ok must be called with i_mutex held.
*/
int inode_newsize_ok(const struct inode *inode, loff_t offset)
{
Expand Down Expand Up @@ -104,17 +104,25 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
}
EXPORT_SYMBOL(inode_newsize_ok);

int inode_setattr(struct inode * inode, struct iattr * attr)
/**
* generic_setattr - copy simple metadata updates into the generic inode
* @inode: the inode to be updated
* @attr: the new attributes
*
* generic_setattr must be called with i_mutex held.
*
* generic_setattr updates the inode's metadata with that specified
* in attr. Noticably missing is inode size update, which is more complex
* as it requires pagecache updates. See simple_setsize.
*
* The inode is not marked as dirty after this operation. The rationale is
* that for "simple" filesystems, the struct inode is the inode storage.
* The caller is free to mark the inode dirty afterwards if needed.
*/
void generic_setattr(struct inode *inode, const struct iattr *attr)
{
unsigned int ia_valid = attr->ia_valid;

if (ia_valid & ATTR_SIZE &&
attr->ia_size != i_size_read(inode)) {
int error = vmtruncate(inode, attr->ia_size);
if (error)
return error;
}

if (ia_valid & ATTR_UID)
inode->i_uid = attr->ia_uid;
if (ia_valid & ATTR_GID)
Expand All @@ -135,6 +143,28 @@ int inode_setattr(struct inode * inode, struct iattr * attr)
mode &= ~S_ISGID;
inode->i_mode = mode;
}
}
EXPORT_SYMBOL(generic_setattr);

/*
* note this function is deprecated, the new truncate sequence should be
* used instead -- see eg. simple_setsize, generic_setattr.
*/
int inode_setattr(struct inode *inode, const struct iattr *attr)
{
unsigned int ia_valid = attr->ia_valid;

if (ia_valid & ATTR_SIZE &&
attr->ia_size != i_size_read(inode)) {
int error;

error = vmtruncate(inode, attr->ia_size);
if (error)
return error;
}

generic_setattr(inode, attr);

mark_inode_dirty(inode);

return 0;
Expand Down
3 changes: 1 addition & 2 deletions fs/bad_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ static int bad_file_release(struct inode *inode, struct file *filp)
return -EIO;
}

static int bad_file_fsync(struct file *file, struct dentry *dentry,
int datasync)
static int bad_file_fsync(struct file *file, int datasync)
{
return -EIO;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/bfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir)
const struct file_operations bfs_dir_operations = {
.read = generic_read_dir,
.readdir = bfs_readdir,
.fsync = simple_fsync,
.fsync = generic_file_fsync,
.llseek = generic_file_llseek,
};

Expand Down
16 changes: 6 additions & 10 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;

return blockdev_direct_IO_no_locking(rw, iocb, inode, I_BDEV(inode),
iov, offset, nr_segs, blkdev_get_blocks, NULL);
return blockdev_direct_IO_no_locking_newtrunc(rw, iocb, inode,
I_BDEV(inode), iov, offset, nr_segs,
blkdev_get_blocks, NULL);
}

int __sync_blockdev(struct block_device *bdev, int wait)
Expand Down Expand Up @@ -309,8 +310,8 @@ static int blkdev_write_begin(struct file *file, struct address_space *mapping,
struct page **pagep, void **fsdata)
{
*pagep = NULL;
return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
blkdev_get_block);
return block_write_begin_newtrunc(file, mapping, pos, len, flags,
pagep, fsdata, blkdev_get_block);
}

static int blkdev_write_end(struct file *file, struct address_space *mapping,
Expand Down Expand Up @@ -358,12 +359,7 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin)
return retval;
}

/*
* Filp is never NULL; the only case when ->fsync() is called with
* NULL first argument is nfsd_sync_dir() and that's not a directory.
*/

int blkdev_fsync(struct file *filp, struct dentry *dentry, int datasync)
int blkdev_fsync(struct file *filp, int datasync)
{
struct inode *bd_inode = filp->f_mapping->host;
struct block_device *bdev = I_BDEV(bd_inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,7 @@ void btrfs_update_iflags(struct inode *inode);
void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);

/* file.c */
int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
int btrfs_sync_file(struct file *file, int datasync);
int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
int skip_pinned);
int btrfs_check_file(struct btrfs_root *root, struct inode *inode);
Expand Down
3 changes: 2 additions & 1 deletion fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,9 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
* important optimization for directories because holding the mutex prevents
* new operations on the dir while we write to disk.
*/
int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
int btrfs_sync_file(struct file *file, int datasync)
{
struct dentry *dentry = file->f_path.dentry;
struct inode *inode = dentry->d_inode;
struct btrfs_root *root = BTRFS_I(inode)->root;
int ret = 0;
Expand Down
Loading

0 comments on commit 89ad6a6

Please sign in to comment.