Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2964
b: refs/heads/master
c: dfb388b
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Jun 23, 2005
1 parent 678fa05 commit 3413595
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 01890a4c120f68366441bf5e193d1b9dd543d4d0
refs/heads/master: dfb388bf8a328f206bba33933dd97230f412238b
45 changes: 10 additions & 35 deletions trunk/fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
return ret;
}

asmlinkage long sys_fsync(unsigned int fd)
static long do_fsync(unsigned int fd, int datasync)
{
struct file * file;
struct address_space *mapping;
Expand All @@ -342,14 +342,14 @@ asmlinkage long sys_fsync(unsigned int fd)
if (!file)
goto out;

mapping = file->f_mapping;

ret = -EINVAL;
if (!file->f_op || !file->f_op->fsync) {
/* Why? We can still call filemap_fdatawrite */
goto out_putf;
}

mapping = file->f_mapping;

current->flags |= PF_SYNCWRITE;
ret = filemap_fdatawrite(mapping);

Expand All @@ -358,7 +358,7 @@ asmlinkage long sys_fsync(unsigned int fd)
* which could cause livelocks in fsync_buffers_list
*/
down(&mapping->host->i_sem);
err = file->f_op->fsync(file, file->f_dentry, 0);
err = file->f_op->fsync(file, file->f_dentry, datasync);
if (!ret)
ret = err;
up(&mapping->host->i_sem);
Expand All @@ -373,39 +373,14 @@ asmlinkage long sys_fsync(unsigned int fd)
return ret;
}

asmlinkage long sys_fdatasync(unsigned int fd)
asmlinkage long sys_fsync(unsigned int fd)
{
struct file * file;
struct address_space *mapping;
int ret, err;

ret = -EBADF;
file = fget(fd);
if (!file)
goto out;

ret = -EINVAL;
if (!file->f_op || !file->f_op->fsync)
goto out_putf;

mapping = file->f_mapping;

current->flags |= PF_SYNCWRITE;
ret = filemap_fdatawrite(mapping);
down(&mapping->host->i_sem);
err = file->f_op->fsync(file, file->f_dentry, 1);
if (!ret)
ret = err;
up(&mapping->host->i_sem);
err = filemap_fdatawait(mapping);
if (!ret)
ret = err;
current->flags &= ~PF_SYNCWRITE;
return do_fsync(fd, 0);
}

out_putf:
fput(file);
out:
return ret;
asmlinkage long sys_fdatasync(unsigned int fd)
{
return do_fsync(fd, 1);
}

/*
Expand Down

0 comments on commit 3413595

Please sign in to comment.