diff options
Diffstat (limited to 'fs/nilfs2/segment.c')
-rw-r--r-- | fs/nilfs2/segment.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 79acf4d66e88..cb004ebe7895 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -1382,14 +1382,14 @@ static void nilfs_segctor_free_incomplete_segments(struct nilfs_sc_info *sci, | |||
1382 | struct the_nilfs *nilfs) | 1382 | struct the_nilfs *nilfs) |
1383 | { | 1383 | { |
1384 | struct nilfs_segment_buffer *segbuf; | 1384 | struct nilfs_segment_buffer *segbuf; |
1385 | int ret, done = 0; | 1385 | int ret; |
1386 | 1386 | ||
1387 | segbuf = NILFS_FIRST_SEGBUF(&sci->sc_segbufs); | 1387 | segbuf = NILFS_FIRST_SEGBUF(&sci->sc_segbufs); |
1388 | if (nilfs->ns_nextnum != segbuf->sb_nextnum) { | 1388 | if (nilfs->ns_nextnum != segbuf->sb_nextnum) { |
1389 | ret = nilfs_sufile_free(nilfs->ns_sufile, segbuf->sb_nextnum); | 1389 | ret = nilfs_sufile_free(nilfs->ns_sufile, segbuf->sb_nextnum); |
1390 | WARN_ON(ret); /* never fails */ | 1390 | WARN_ON(ret); /* never fails */ |
1391 | } | 1391 | } |
1392 | if (segbuf->sb_io_error) { | 1392 | if (atomic_read(&segbuf->sb_err)) { |
1393 | /* Case 1: The first segment failed */ | 1393 | /* Case 1: The first segment failed */ |
1394 | if (segbuf->sb_pseg_start != segbuf->sb_fseg_start) | 1394 | if (segbuf->sb_pseg_start != segbuf->sb_fseg_start) |
1395 | /* Case 1a: Partial segment appended into an existing | 1395 | /* Case 1a: Partial segment appended into an existing |
@@ -1398,19 +1398,16 @@ static void nilfs_segctor_free_incomplete_segments(struct nilfs_sc_info *sci, | |||
1398 | segbuf->sb_fseg_end); | 1398 | segbuf->sb_fseg_end); |
1399 | else /* Case 1b: New full segment */ | 1399 | else /* Case 1b: New full segment */ |
1400 | set_nilfs_discontinued(nilfs); | 1400 | set_nilfs_discontinued(nilfs); |
1401 | done++; | ||
1402 | } | 1401 | } |
1403 | 1402 | ||
1404 | list_for_each_entry_continue(segbuf, &sci->sc_segbufs, sb_list) { | 1403 | list_for_each_entry_continue(segbuf, &sci->sc_segbufs, sb_list) { |
1405 | ret = nilfs_sufile_free(nilfs->ns_sufile, segbuf->sb_nextnum); | 1404 | ret = nilfs_sufile_free(nilfs->ns_sufile, segbuf->sb_nextnum); |
1406 | WARN_ON(ret); /* never fails */ | 1405 | WARN_ON(ret); /* never fails */ |
1407 | if (!done && segbuf->sb_io_error) { | 1406 | if (atomic_read(&segbuf->sb_err) && |
1408 | if (segbuf->sb_segnum != nilfs->ns_nextnum) | 1407 | segbuf->sb_segnum != nilfs->ns_nextnum) |
1409 | /* Case 2: extended segment (!= next) failed */ | 1408 | /* Case 2: extended segment (!= next) failed */ |
1410 | nilfs_sufile_set_error(nilfs->ns_sufile, | 1409 | nilfs_sufile_set_error(nilfs->ns_sufile, |
1411 | segbuf->sb_segnum); | 1410 | segbuf->sb_segnum); |
1412 | done++; | ||
1413 | } | ||
1414 | } | 1411 | } |
1415 | } | 1412 | } |
1416 | 1413 | ||
@@ -1801,7 +1798,7 @@ static int nilfs_segctor_write(struct nilfs_sc_info *sci, | |||
1801 | nilfs_segbuf_prepare_write(segbuf, &wi); | 1798 | nilfs_segbuf_prepare_write(segbuf, &wi); |
1802 | err = nilfs_segbuf_write(segbuf, &wi); | 1799 | err = nilfs_segbuf_write(segbuf, &wi); |
1803 | 1800 | ||
1804 | res = nilfs_segbuf_wait(segbuf, &wi); | 1801 | res = nilfs_segbuf_wait(segbuf); |
1805 | err = err ? : res; | 1802 | err = err ? : res; |
1806 | if (err) | 1803 | if (err) |
1807 | return err; | 1804 | return err; |