Skip to content

Commit dd7f3d5

Browse files
khoroshilovChristoph Hellwig
authored andcommitted
hfsplus: Add error propagation for hfsplus_ext_write_extent_locked
Implement error propagation through the callers of hfsplus_ext_write_extent_locked(). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 5bd9d99 commit dd7f3d5

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

‎fs/hfsplus/extents.c‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,31 @@ static void __hfsplus_ext_write_extent(struct inode *inode,
119119
set_bit(HFSPLUS_I_EXT_DIRTY, &hip->flags);
120120
}
121121

122-
static void hfsplus_ext_write_extent_locked(struct inode *inode)
122+
static int hfsplus_ext_write_extent_locked(struct inode *inode)
123123
{
124+
int res;
125+
124126
if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
125127
struct hfs_find_data fd;
126128

127-
if (!hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd)) {
128-
__hfsplus_ext_write_extent(inode, &fd);
129-
hfs_find_exit(&fd);
130-
}
129+
res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
130+
if (res)
131+
return res;
132+
__hfsplus_ext_write_extent(inode, &fd);
133+
hfs_find_exit(&fd);
131134
}
135+
return 0;
132136
}
133137

134-
void hfsplus_ext_write_extent(struct inode *inode)
138+
int hfsplus_ext_write_extent(struct inode *inode)
135139
{
140+
int res;
141+
136142
mutex_lock(&HFSPLUS_I(inode)->extents_lock);
137-
hfsplus_ext_write_extent_locked(inode);
143+
res = hfsplus_ext_write_extent_locked(inode);
138144
mutex_unlock(&HFSPLUS_I(inode)->extents_lock);
145+
146+
return res;
139147
}
140148

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

478486
insert_extent:
479487
dprint(DBG_EXTENT, "insert new extent\n");
480-
hfsplus_ext_write_extent_locked(inode);
488+
res = hfsplus_ext_write_extent_locked(inode);
489+
if (res)
490+
goto out;
481491

482492
memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
483493
hip->cached_extents[0].start_block = cpu_to_be32(start);

‎fs/hfsplus/hfsplus_fs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ extern const struct file_operations hfsplus_dir_operations;
374374

375375
/* extents.c */
376376
int hfsplus_ext_cmp_key(const hfsplus_btree_key *, const hfsplus_btree_key *);
377-
void hfsplus_ext_write_extent(struct inode *);
377+
int hfsplus_ext_write_extent(struct inode *);
378378
int hfsplus_get_block(struct inode *, sector_t, struct buffer_head *, int);
379379
int hfsplus_free_fork(struct super_block *, u32,
380380
struct hfsplus_fork_raw *, int);

‎fs/hfsplus/super.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,13 @@ static int hfsplus_system_write_inode(struct inode *inode)
135135
static int hfsplus_write_inode(struct inode *inode,
136136
struct writeback_control *wbc)
137137
{
138+
int err;
139+
138140
dprint(DBG_INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);
139141

140-
hfsplus_ext_write_extent(inode);
142+
err = hfsplus_ext_write_extent(inode);
143+
if (err)
144+
return err;
141145

142146
if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID ||
143147
inode->i_ino == HFSPLUS_ROOT_CNID)

0 commit comments

Comments
 (0)