aboutsummaryrefslogtreecommitdiffstats
path: root/fs/logfs/readwrite.c
diff options
context:
space:
mode:
authorJoern Engel <joern@logfs.org>2010-05-04 13:41:09 -0400
committerJoern Engel <joern@logfs.org>2010-05-04 13:41:09 -0400
commit05ebad852901cf9127a743df6ea10c0e8b1590c3 (patch)
treeeb5e200d3ca4ae15bec2cbf3731055ff29e7f73c /fs/logfs/readwrite.c
parent20503664b008e17976bff1fdbc693c77ebd6f6c9 (diff)
logfs: commit reservations under space pressure
Ensures we only return -ENOSPC when there really is no space. Signed-off-by: Joern Engel <joern@logfs.org>
Diffstat (limited to 'fs/logfs/readwrite.c')
-rw-r--r--fs/logfs/readwrite.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/logfs/readwrite.c b/fs/logfs/readwrite.c
index e37cee3b1007..0718d112a1a5 100644
--- a/fs/logfs/readwrite.c
+++ b/fs/logfs/readwrite.c
@@ -1095,17 +1095,25 @@ static int logfs_reserve_bytes(struct inode *inode, int bytes)
1095int get_page_reserve(struct inode *inode, struct page *page) 1095int get_page_reserve(struct inode *inode, struct page *page)
1096{ 1096{
1097 struct logfs_super *super = logfs_super(inode->i_sb); 1097 struct logfs_super *super = logfs_super(inode->i_sb);
1098 struct logfs_block *block = logfs_block(page);
1098 int ret; 1099 int ret;
1099 1100
1100 if (logfs_block(page) && logfs_block(page)->reserved_bytes) 1101 if (block && block->reserved_bytes)
1101 return 0; 1102 return 0;
1102 1103
1103 logfs_get_wblocks(inode->i_sb, page, WF_LOCK); 1104 logfs_get_wblocks(inode->i_sb, page, WF_LOCK);
1104 ret = logfs_reserve_bytes(inode, 6 * LOGFS_MAX_OBJECTSIZE); 1105 while ((ret = logfs_reserve_bytes(inode, 6 * LOGFS_MAX_OBJECTSIZE)) &&
1106 !list_empty(&super->s_writeback_list)) {
1107 block = list_entry(super->s_writeback_list.next,
1108 struct logfs_block, alias_list);
1109 block->ops->write_block(block);
1110 }
1105 if (!ret) { 1111 if (!ret) {
1106 alloc_data_block(inode, page); 1112 alloc_data_block(inode, page);
1107 logfs_block(page)->reserved_bytes += 6 * LOGFS_MAX_OBJECTSIZE; 1113 block = logfs_block(page);
1114 block->reserved_bytes += 6 * LOGFS_MAX_OBJECTSIZE;
1108 super->s_dirty_pages += 6 * LOGFS_MAX_OBJECTSIZE; 1115 super->s_dirty_pages += 6 * LOGFS_MAX_OBJECTSIZE;
1116 list_move_tail(&block->alias_list, &super->s_writeback_list);
1109 } 1117 }
1110 logfs_put_wblocks(inode->i_sb, page, WF_LOCK); 1118 logfs_put_wblocks(inode->i_sb, page, WF_LOCK);
1111 return ret; 1119 return ret;
@@ -2251,6 +2259,7 @@ int logfs_init_rw(struct super_block *sb)
2251 int min_fill = 3 * super->s_no_blocks; 2259 int min_fill = 3 * super->s_no_blocks;
2252 2260
2253 INIT_LIST_HEAD(&super->s_object_alias); 2261 INIT_LIST_HEAD(&super->s_object_alias);
2262 INIT_LIST_HEAD(&super->s_writeback_list);
2254 mutex_init(&super->s_write_mutex); 2263 mutex_init(&super->s_write_mutex);
2255 super->s_block_pool = mempool_create_kmalloc_pool(min_fill, 2264 super->s_block_pool = mempool_create_kmalloc_pool(min_fill,
2256 sizeof(struct logfs_block)); 2265 sizeof(struct logfs_block));