Skip to content

Commit 5758b5d

Browse files
committed
TDB: check fallocate() result to properly handle disk out of space issue
1 parent 68f1a59 commit 5758b5d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tempesta_db/core/file.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ tempesta_unmap_file(struct file *file, unsigned long addr, unsigned long len,
267267
int
268268
tdb_file_open(TDB *db, unsigned long size)
269269
{
270-
unsigned long addr;
270+
unsigned long ret, addr;
271271
struct file *filp;
272272
struct inode *inode;
273273

@@ -287,8 +287,13 @@ tdb_file_open(TDB *db, unsigned long size)
287287
/* Allocate continous extents. */
288288
inode = file_inode(filp);
289289
sb_start_write(inode->i_sb);
290-
filp->f_op->fallocate(filp, 0, 0, size);
290+
ret = filp->f_op->fallocate(filp, 0, 0, size);
291291
sb_end_write(inode->i_sb);
292+
if (ret) {
293+
TDB_ERR("Cannot fallocate file, %ld\n", ret);
294+
filp_close(db->filp, NULL);
295+
return ret;
296+
}
292297

293298
addr = tempesta_map_file(filp, size, db->node);
294299
if (IS_ERR((void *)addr)) {

0 commit comments

Comments
 (0)