Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360447
b: refs/heads/master
c: 38851cc
h: refs/heads/master
i:
  360445: 732f97a
  360443: 40a2433
  360439: c8c423e
  360431: 649fa5c
  360415: 214ebbc
  360383: aa94030
  360319: 0e13771
  360191: efb9466
  359935: 6ffb6bd
  359423: afe6e6d
  358399: 13c6cfd
  356351: 0d2f364
  352255: 8f9982f
  344063: 542864c
  327679: 9dd685f
v: v3
  • Loading branch information
Miao Xie authored and Josef Bacik committed Feb 20, 2013
1 parent 2fdee1e commit 3a4bf49
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 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: 2e60a51e62185cce48758e596ae7cb2da673b58f
refs/heads/master: 38851cc19adbfa1def2b47106d8050a80e0a3673
35 changes: 23 additions & 12 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6677,28 +6677,36 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
struct inode *inode = file->f_mapping->host;
size_t count = 0;
int flags = 0;
bool wakeup = false;
bool wakeup = true;
bool relock = false;
ssize_t ret;

if (check_direct_IO(BTRFS_I(inode)->root, rw, iocb, iov,
offset, nr_segs))
return 0;

atomic_inc(&inode->i_dio_count);
smp_mb__after_atomic_inc();

if (rw & WRITE) {
count = iov_length(iov, nr_segs);
/*
* If the write DIO is beyond the EOF, we need update
* the isize, but it is protected by i_mutex. So we can
* not unlock the i_mutex at this case.
*/
if (offset + count <= inode->i_size) {
mutex_unlock(&inode->i_mutex);
relock = true;
}
ret = btrfs_delalloc_reserve_space(inode, count);
if (ret)
return ret;
} else {
atomic_inc(&inode->i_dio_count);
smp_mb__after_atomic_inc();
if (unlikely(test_bit(BTRFS_INODE_READDIO_NEED_LOCK,
&BTRFS_I(inode)->runtime_flags))) {
inode_dio_done(inode);
flags = DIO_LOCKING | DIO_SKIP_HOLES;
} else {
wakeup = true;
}
goto out;
} else if (unlikely(test_bit(BTRFS_INODE_READDIO_NEED_LOCK,
&BTRFS_I(inode)->runtime_flags))) {
inode_dio_done(inode);
flags = DIO_LOCKING | DIO_SKIP_HOLES;
wakeup = false;
}

ret = __blockdev_direct_IO(rw, iocb, inode,
Expand All @@ -6717,8 +6725,11 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
}
btrfs_delalloc_release_metadata(inode, 0);
}
out:
if (wakeup)
inode_dio_done(inode);
if (relock)
mutex_lock(&inode->i_mutex);

return ret;
}
Expand Down

0 comments on commit 3a4bf49

Please sign in to comment.