Skip to contentSkip to conversation

ext4: retry failed direct IO allocations

PATCH In review Eric Sandeen 2 participants 2 messages Oct 2, 2009 – Oct 3, 2009 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: retry failed direct IO allocations

On a 256M filesystem, doing this in a loop:

xfs_io -F -f -d -c 'pwrite 0 64m' test
rm -f test

eventually leads to ENOSPC. (the xfs_io command does a 64m direct IO write to the file "test")

As with other block allocation callers, it looks like we need to potentially retry the allocations on the initial ENOSPC.

---

fs/ext4/inode.c +0 -0
index 4abd683..098c466 100644
@@ -3291,6 +3291,7 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
	ssize_t ret;
	int orphan = 0;
	size_t count = iov_length(iov, nr_segs);

+ int retries = 0;

	if (rw == WRITE) {
		loff_t final_size = offset + count;
@@ -3313,9 +3314,12 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
		}
	}

+retry:

	ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
				 offset, nr_segs,
				 ext4_get_block, NULL);

+ if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+ goto retry;

	if (orphan) {
		int err;
maintainer
#1 lore raw
Quoted 5 lines · Eric Sandeen

On a 256M filesystem, doing this in a loop:

xfs_io -F -f -d -c 'pwrite 0 64m' test
rm -f test

Quoted 7 lines

eventually leads to ENOSPC. (the xfs_io command does a 64m direct IO write to the file "test")

As with other block allocation callers, it looks like we need to potentially retry the allocations on the initial ENOSPC.

Thanks, added to the ext4 patch queue.

- Ted