fs/gfs2/sys.c

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

File Facts

System
Linux kernel
Corpus path
fs/gfs2/sys.c
Extension
.c
Size
20611 bytes
Lines
798
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

struct gfs2_attr {
	struct attribute attr;
	ssize_t (*show)(struct gfs2_sbd *, char *);
	ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
};

static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr,
			      char *buf)
{
	struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
	struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
	return a->show ? a->show(sdp, buf) : 0;
}

static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
			       const char *buf, size_t len)
{
	struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
	struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
	return a->store ? a->store(sdp, buf, len) : len;
}

static const struct sysfs_ops gfs2_attr_ops = {
	.show  = gfs2_attr_show,
	.store = gfs2_attr_store,
};


static struct kset *gfs2_kset;

static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
{
	return sysfs_emit(buf, "%u:%u\n",
			MAJOR(sdp->sd_vfs->s_dev), MINOR(sdp->sd_vfs->s_dev));
}

static ssize_t status_show(struct gfs2_sbd *sdp, char *buf)
{
	unsigned long f = sdp->sd_flags;
	ssize_t s;

	s = sysfs_emit(buf,
		     "Journal Checked:          %d\n"
		     "Journal Live:             %d\n"
		     "Journal ID:               %d\n"
		     "Spectator:                %d\n"
		     "Withdrawn:                %d\n"
		     "No barriers:              %d\n"
		     "No recovery:              %d\n"
		     "Demote:                   %d\n"
		     "No Journal ID:            %d\n"
		     "Mounted RO:               %d\n"
		     "RO Recovery:              %d\n"
		     "Skip DLM Unlock:          %d\n"
		     "Force AIL Flush:          %d\n"
		     "FS Freeze Initiator:      %d\n"
		     "FS Frozen:                %d\n"
		     "Killing:                  %d\n"
		     "sd_log_error:             %d\n"
		     "sd_log_flush_lock:        %d\n"
		     "sd_log_num_revoke:        %u\n"
		     "sd_log_in_flight:         %d\n"
		     "sd_log_blks_needed:       %d\n"
		     "sd_log_blks_free:         %d\n"
		     "sd_log_flush_head:        %d\n"
		     "sd_log_flush_tail:        %d\n"
		     "sd_log_blks_reserved:     %d\n"
		     "sd_log_revokes_available: %d\n"
		     "sd_log_pinned:            %d\n"
		     "sd_log_thresh1:           %d\n"
		     "sd_log_thresh2:           %d\n",
		     test_bit(SDF_JOURNAL_CHECKED, &f),
		     test_bit(SDF_JOURNAL_LIVE, &f),
		     (sdp->sd_jdesc ? sdp->sd_jdesc->jd_jid : 0),
		     (sdp->sd_args.ar_spectator ? 1 : 0),
		     test_bit(SDF_WITHDRAWN, &f),
		     test_bit(SDF_NOBARRIERS, &f),
		     test_bit(SDF_NORECOVERY, &f),
		     test_bit(SDF_DEMOTE, &f),
		     test_bit(SDF_NOJOURNALID, &f),
		     (sb_rdonly(sdp->sd_vfs) ? 1 : 0),
		     test_bit(SDF_RORECOVERY, &f),
		     test_bit(SDF_SKIP_DLM_UNLOCK, &f),
		     test_bit(SDF_FORCE_AIL_FLUSH, &f),
		     test_bit(SDF_FREEZE_INITIATOR, &f),
		     test_bit(SDF_FROZEN, &f),
		     test_bit(SDF_KILL, &f),
		     sdp->sd_log_error,
		     rwsem_is_locked(&sdp->sd_log_flush_lock),
		     sdp->sd_log_num_revoke,

Annotation

Implementation Notes