Skip to content

Commit

Permalink
hfsplus: Add error propagation for hfsplus_ext_write_extent_locked
Browse files Browse the repository at this point in the history
Implement error propagation through the callers of
hfsplus_ext_write_extent_locked().

Signed-off-by: Alexey Khoroshilov <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
khoroshilov authored and Christoph Hellwig committed Jul 7, 2011
1 parent 5bd9d99 commit dd7f3d5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
26 changes: 18 additions & 8 deletions fs/hfsplus/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,31 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
set_bit(HFSPLUS_I_EXT_DIRTY, &hip->flags);
}

static void hfsplus_ext_write_extent_locked(struct inode *inode)
static int hfsplus_ext_write_extent_locked(struct inode *inode)
{
int res;

if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
struct hfs_find_data fd;

if (!hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd)) {
__hfsplus_ext_write_extent(inode, &fd);
hfs_find_exit(&fd);
}
res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
if (res)
return res;
__hfsplus_ext_write_extent(inode, &fd);
hfs_find_exit(&fd);
}
return 0;
}

void hfsplus_ext_write_extent(struct inode *inode)
int hfsplus_ext_write_extent(struct inode *inode)
{
int res;

mutex_lock(&HFSPLUS_I(inode)->extents_lock);
hfsplus_ext_write_extent_locked(inode);
res = hfsplus_ext_write_extent_locked(inode);
mutex_unlock(&HFSPLUS_I(inode)->extents_lock);

return res;
}

static inline int __hfsplus_ext_read_extent(struct hfs_find_data *fd,
Expand Down Expand Up @@ -477,7 +485,9 @@ int hfsplus_file_extend(struct inode *inode)

insert_extent:
dprint(DBG_EXTENT, "insert new extent\n");
hfsplus_ext_write_extent_locked(inode);
res = hfsplus_ext_write_extent_locked(inode);
if (res)
goto out;

memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
hip->cached_extents[0].start_block = cpu_to_be32(start);
Expand Down
2 changes: 1 addition & 1 deletion fs/hfsplus/hfsplus_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ extern const struct file_operations hfsplus_dir_operations;

/* extents.c */
int hfsplus_ext_cmp_key(const hfsplus_btree_key *, const hfsplus_btree_key *);
void hfsplus_ext_write_extent(struct inode *);
int hfsplus_ext_write_extent(struct inode *);
int hfsplus_get_block(struct inode *, sector_t, struct buffer_head *, int);
int hfsplus_free_fork(struct super_block *, u32,
struct hfsplus_fork_raw *, int);
Expand Down
6 changes: 5 additions & 1 deletion fs/hfsplus/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ static int hfsplus_system_write_inode(struct inode *inode)
static int hfsplus_write_inode(struct inode *inode,
struct writeback_control *wbc)
{
int err;

dprint(DBG_INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);

hfsplus_ext_write_extent(inode);
err = hfsplus_ext_write_extent(inode);
if (err)
return err;

if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID ||
inode->i_ino == HFSPLUS_ROOT_CNID)
Expand Down

0 comments on commit dd7f3d5

Please sign in to comment.