Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23445
b: refs/heads/master
c: 18e79b4
h: refs/heads/master
i:
  23443: 19a6f38
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Mar 24, 2006
1 parent defcc07 commit 8dafb20
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 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: 676758bdb7bfca8413a85203921746f446e237be
refs/heads/master: 18e79b40ed9c5223b88771f805c69f5993fc131b
43 changes: 23 additions & 20 deletions trunk/fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,31 +327,24 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
return ret;
}

static long do_fsync(unsigned int fd, int datasync)
long do_fsync(struct file *file, int datasync)
{
struct file * file;
struct address_space *mapping;
int ret, err;

ret = -EBADF;
file = fget(fd);
if (!file)
goto out;
int ret;
int err;
struct address_space *mapping = file->f_mapping;

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

mapping = file->f_mapping;

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

/*
* We need to protect against concurrent writers,
* which could cause livelocks in fsync_buffers_list
* We need to protect against concurrent writers, which could cause
* livelocks in fsync_buffers_list().
*/
mutex_lock(&mapping->host->i_mutex);
err = file->f_op->fsync(file, file->f_dentry, datasync);
Expand All @@ -362,21 +355,31 @@ static long do_fsync(unsigned int fd, int datasync)
if (!ret)
ret = err;
current->flags &= ~PF_SYNCWRITE;

out_putf:
fput(file);
out:
return ret;
}

static long __do_fsync(unsigned int fd, int datasync)
{
struct file *file;
int ret = -EBADF;

file = fget(fd);
if (file) {
ret = do_fsync(file, datasync);
fput(file);
}
return ret;
}

asmlinkage long sys_fsync(unsigned int fd)
{
return do_fsync(fd, 0);
return __do_fsync(fd, 0);
}

asmlinkage long sys_fdatasync(unsigned int fd)
{
return do_fsync(fd, 1);
return __do_fsync(fd, 1);
}

/*
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,7 @@ extern int wait_on_page_writeback_range(struct address_space *mapping,
extern int __filemap_fdatawrite_range(struct address_space *mapping,
loff_t start, loff_t end, int sync_mode);

extern long do_fsync(struct file *file, int datasync);
extern void sync_supers(void);
extern void sync_filesystems(int wait);
extern void emergency_sync(void);
Expand Down

0 comments on commit 8dafb20

Please sign in to comment.