fs/gfs2/util.c

Source file repositories/reference/linux-study-clean/fs/gfs2/util.c

File Facts

System
Linux kernel
Corpus path
fs/gfs2/util.c
Extension
.c
Size
11424 bytes
Lines
437
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

if (device_inactive) {
			lm->lm_unmount(sdp, false);
			do_withdraw(sdp);
		} else {
			do_withdraw(sdp);
			lm->lm_unmount(sdp, false);
		}
	} else {
		do_withdraw(sdp);
	}

	fs_err(sdp, "file system withdrawn\n");
}

void gfs2_withdraw(struct gfs2_sbd *sdp)
{
	if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW ||
	    sdp->sd_args.ar_errors == GFS2_ERRORS_DEACTIVATE) {
		if (test_and_set_bit(SDF_WITHDRAWN, &sdp->sd_flags))
			return;

		dump_stack();
		/*
		 * There is no need to withdraw when the superblock hasn't been
		 * fully initialized, yet.
		 */
		if (!(sdp->sd_vfs->s_flags & SB_BORN))
			return;
		fs_err(sdp, "about to withdraw this file system\n");
		schedule_work(&sdp->sd_withdraw_work);
		return;
	}

	if (sdp->sd_args.ar_errors == GFS2_ERRORS_PANIC)
		panic("GFS2: fsid=%s: panic requested\n", sdp->sd_fsname);
}

/*
 * gfs2_assert_withdraw_i - Cause the machine to withdraw if @assertion is false
 */

void gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
			    const char *function, char *file, unsigned int line)
{
	if (gfs2_withdrawn(sdp))
		return;

	fs_err(sdp,
	       "fatal: assertion \"%s\" failed - "
	       "function = %s, file = %s, line = %u\n",
	       assertion, function, file, line);

	gfs2_withdraw(sdp);
	dump_stack();
}

/*
 * gfs2_assert_warn_i - Print a message to the console if @assertion is false
 */

void gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
			const char *function, char *file, unsigned int line)
{
	if (time_before(jiffies,
			sdp->sd_last_warning +
			gfs2_tune_get(sdp, gt_complain_secs) * HZ))
		return;

	if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW)
		fs_warn(sdp, "warning: assertion \"%s\" failed - "
			"function = %s, file = %s, line = %u\n",
			assertion, function, file, line);

	if (sdp->sd_args.ar_debug)
		BUG();
	else
		dump_stack();

	if (sdp->sd_args.ar_errors == GFS2_ERRORS_PANIC)
		panic("GFS2: fsid=%s: warning: assertion \"%s\" failed - "
		      "function = %s, file = %s, line = %u\n",
		      sdp->sd_fsname, assertion,
		      function, file, line);

	sdp->sd_last_warning = jiffies;
}

/*
 * gfs2_consist_i - Flag a filesystem consistency error and withdraw
 */

Annotation

Implementation Notes