Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 143179
b: refs/heads/master
c: 8de2bf9
h: refs/heads/master
i:
  143177: 94bc861
  143175: e7b3ccc
v: v3
  • Loading branch information
Dave Chinner authored and Christoph Hellwig committed Apr 6, 2009
1 parent b110a5a commit e1a4ec2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 49 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: 153fec43ce5264dfe9f3530b281a2e940b25a0a8
refs/heads/master: 8de2bf937a6bea8f0f775fd5399ba20c1a0c3d77
61 changes: 15 additions & 46 deletions trunk/fs/xfs/xfs_iomap.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,38 +337,6 @@ xfs_iomap_eof_align_last_fsb(
return 0;
}

STATIC int
xfs_flush_space(
xfs_inode_t *ip,
int *fsynced,
int *ioflags)
{
switch (*fsynced) {
case 0:
if (ip->i_delayed_blks) {
xfs_iunlock(ip, XFS_ILOCK_EXCL);
delay(1);
xfs_ilock(ip, XFS_ILOCK_EXCL);
*fsynced = 1;
} else {
*ioflags |= BMAPI_SYNC;
*fsynced = 2;
}
return 0;
case 1:
*fsynced = 2;
*ioflags |= BMAPI_SYNC;
return 0;
case 2:
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_flush_inodes(ip);
xfs_ilock(ip, XFS_ILOCK_EXCL);
*fsynced = 3;
return 0;
}
return 1;
}

STATIC int
xfs_cmn_err_fsblock_zero(
xfs_inode_t *ip,
Expand Down Expand Up @@ -538,15 +506,9 @@ xfs_iomap_write_direct(
}

/*
* If the caller is doing a write at the end of the file,
* then extend the allocation out to the file system's write
* iosize. We clean up any extra space left over when the
* file is closed in xfs_inactive().
*
* For sync writes, we are flushing delayed allocate space to
* try to make additional space available for allocation near
* the filesystem full boundary - preallocation hurts in that
* situation, of course.
* If the caller is doing a write at the end of the file, then extend the
* allocation out to the file system's write iosize. We clean up any extra
* space left over when the file is closed in xfs_inactive().
*/
STATIC int
xfs_iomap_eof_want_preallocate(
Expand All @@ -565,7 +527,7 @@ xfs_iomap_eof_want_preallocate(
int n, error, imaps;

*prealloc = 0;
if ((ioflag & BMAPI_SYNC) || (offset + count) <= ip->i_size)
if ((offset + count) <= ip->i_size)
return 0;

/*
Expand Down Expand Up @@ -611,7 +573,7 @@ xfs_iomap_write_delay(
xfs_extlen_t extsz;
int nimaps;
xfs_bmbt_irec_t imap[XFS_WRITE_IMAPS];
int prealloc, fsynced = 0;
int prealloc, flushed = 0;
int error;

ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
Expand All @@ -627,12 +589,12 @@ xfs_iomap_write_delay(
extsz = xfs_get_extsz_hint(ip);
offset_fsb = XFS_B_TO_FSBT(mp, offset);

retry:
error = xfs_iomap_eof_want_preallocate(mp, ip, offset, count,
ioflag, imap, XFS_WRITE_IMAPS, &prealloc);
if (error)
return error;

retry:
if (prealloc) {
aligned_offset = XFS_WRITEIO_ALIGN(mp, (offset + count - 1));
ioalign = XFS_B_TO_FSBT(mp, aligned_offset);
Expand All @@ -659,15 +621,22 @@ xfs_iomap_write_delay(

/*
* If bmapi returned us nothing, and if we didn't get back EDQUOT,
* then we must have run out of space - flush delalloc, and retry..
* then we must have run out of space - flush all other inodes with
* delalloc blocks and retry without EOF preallocation.
*/
if (nimaps == 0) {
xfs_iomap_enter_trace(XFS_IOMAP_WRITE_NOSPACE,
ip, offset, count);
if (xfs_flush_space(ip, &fsynced, &ioflag))
if (flushed)
return XFS_ERROR(ENOSPC);

xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_flush_inodes(ip);
xfs_ilock(ip, XFS_ILOCK_EXCL);

flushed = 1;
error = 0;
prealloc = 0;
goto retry;
}

Expand Down
3 changes: 1 addition & 2 deletions trunk/fs/xfs/xfs_iomap.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ typedef enum {
BMAPI_IGNSTATE = (1 << 4), /* ignore unwritten state on read */
BMAPI_DIRECT = (1 << 5), /* direct instead of buffered write */
BMAPI_MMAP = (1 << 6), /* allocate for mmap write */
BMAPI_SYNC = (1 << 7), /* sync write to flush delalloc space */
BMAPI_TRYLOCK = (1 << 8), /* non-blocking request */
BMAPI_TRYLOCK = (1 << 7), /* non-blocking request */
} bmapi_flags_t;


Expand Down

0 comments on commit e1a4ec2

Please sign in to comment.