Unverified Commit 0dca970a authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12247 nilfs2: fix state management in error path of log writing function

parents b43e2b29 2eac555b
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1806,6 +1806,9 @@ static void nilfs_segctor_abort_construction(struct nilfs_sc_info *sci,
	nilfs_abort_logs(&logs, ret ? : err);

	list_splice_tail_init(&sci->sc_segbufs, &logs);
	if (list_empty(&logs))
		return; /* if the first segment buffer preparation failed */

	nilfs_cancel_segusage(&logs, nilfs->ns_sufile);
	nilfs_free_incomplete_logs(&logs, nilfs);

@@ -2047,7 +2050,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)

		err = nilfs_segctor_begin_construction(sci, nilfs);
		if (unlikely(err))
			goto out;
			goto failed;

		/* Update time stamp */
		sci->sc_seg_ctime = ktime_get_real_seconds();
@@ -2110,10 +2113,9 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
	return err;

 failed_to_write:
	if (sci->sc_stage.flags & NILFS_CF_IFILE_STARTED)
		nilfs_redirty_inodes(&sci->sc_dirty_files);

 failed:
	if (mode == SC_LSEG_SR && nilfs_sc_cstage_get(sci) >= NILFS_ST_IFILE)
		nilfs_redirty_inodes(&sci->sc_dirty_files);
	if (nilfs_doing_gc())
		nilfs_redirty_inodes(&sci->sc_gc_inodes);
	nilfs_segctor_abort_construction(sci, nilfs, err);