/*
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
- * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License v.2.
+ * of the GNU General Public License version 2.
*/
#include <linux/sched.h>
#include <linux/buffer_head.h>
#include <linux/module.h>
#include <linux/kobject.h>
-#include <asm/semaphore.h>
+#include <linux/gfs2_ondisk.h>
+#include <linux/lm_interface.h>
#include <asm/uaccess.h>
#include "gfs2.h"
+#include "incore.h"
#include "lm.h"
#include "sys.h"
#include "super.h"
#include "glock.h"
#include "quota.h"
+#include "util.h"
char *gfs2_sys_margs;
spinlock_t gfs2_sys_margs_lock;
static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
{
- return sprintf(buf, "%s\n", sdp->sd_vfs->s_id);
+ return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_vfs->s_id);
}
static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf)
{
- return sprintf(buf, "%s\n", sdp->sd_fsname);
+ return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname);
}
static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
count = sdp->sd_freeze_count;
mutex_unlock(&sdp->sd_freeze_lock);
- return sprintf(buf, "%u\n", count);
+ return snprintf(buf, PAGE_SIZE, "%u\n", count);
}
static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)
{
unsigned int b = test_bit(SDF_SHUTDOWN, &sdp->sd_flags);
- return sprintf(buf, "%u\n", b);
+ return snprintf(buf, PAGE_SIZE, "%u\n", b);
}
static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
size_t len)
{
- uint32_t id;
+ u32 id;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
size_t len)
{
- uint32_t id;
+ u32 id;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
static struct kset gfs2_kset = {
.subsys = &fs_subsys,
- .kobj = {.name = "gfs2",},
+ .kobj = {.name = "gfs2"},
.ktype = &gfs2_ktype,
};
#define LOCKSTRUCT_ATTR(name, fmt) \
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
{ \
- return sprintf(buf, fmt, sdp->sd_lockstruct.ls_##name); \
+ return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_lockstruct.ls_##name); \
} \
static struct lockstruct_attr lockstruct_attr_##name = __ATTR_RO(name)
&lockstruct_attr_first.attr,
&lockstruct_attr_lvb_size.attr,
&lockstruct_attr_flags.attr,
- NULL
+ NULL,
};
/*
#define ARGS_ATTR(name, fmt) \
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
{ \
- return sprintf(buf, fmt, sdp->sd_args.ar_##name); \
+ return snprintf(buf, PAGE_SIZE, fmt, sdp->sd_args.ar_##name); \
} \
static struct args_attr args_attr_##name = __ATTR_RO(name)
/* one oddball doesn't fit the macro mold */
static ssize_t noatime_show(struct gfs2_sbd *sdp, char *buf)
{
- return sprintf(buf, "%d\n", !!test_bit(SDF_NOATIME, &sdp->sd_flags));
+ return snprintf(buf, PAGE_SIZE, "%d\n",
+ !!test_bit(SDF_NOATIME, &sdp->sd_flags));
}
static struct args_attr args_attr_noatime = __ATTR_RO(noatime);
&args_attr_suiddir.attr,
&args_attr_data.attr,
&args_attr_noatime.attr,
- NULL
+ NULL,
};
/*
ssize_t (*show)(struct gfs2_sbd *, char *);
};
-#define COUNTERS_ATTR_GENERAL(name, fmt, val) \
+#define COUNTERS_ATTR(name, fmt) \
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
{ \
- return sprintf(buf, fmt, val); \
+ return snprintf(buf, PAGE_SIZE, fmt, \
+ (unsigned int)atomic_read(&sdp->sd_##name)); \
} \
static struct counters_attr counters_attr_##name = __ATTR_RO(name)
-#define COUNTERS_ATTR_SIMPLE(name, fmt) \
- COUNTERS_ATTR_GENERAL(name, fmt, sdp->sd_##name)
-
-#define COUNTERS_ATTR_ATOMIC(name, fmt) \
- COUNTERS_ATTR_GENERAL(name, fmt, (unsigned int)atomic_read(&sdp->sd_##name))
-
-COUNTERS_ATTR_ATOMIC(glock_count, "%u\n");
-COUNTERS_ATTR_ATOMIC(glock_held_count, "%u\n");
-COUNTERS_ATTR_ATOMIC(inode_count, "%u\n");
-COUNTERS_ATTR_ATOMIC(bufdata_count, "%u\n");
-COUNTERS_ATTR_ATOMIC(unlinked_count, "%u\n");
-COUNTERS_ATTR_ATOMIC(quota_count, "%u\n");
-COUNTERS_ATTR_SIMPLE(log_num_gl, "%u\n");
-COUNTERS_ATTR_SIMPLE(log_num_buf, "%u\n");
-COUNTERS_ATTR_SIMPLE(log_num_revoke, "%u\n");
-COUNTERS_ATTR_SIMPLE(log_num_rg, "%u\n");
-COUNTERS_ATTR_SIMPLE(log_num_databuf, "%u\n");
-COUNTERS_ATTR_SIMPLE(log_blks_free, "%u\n");
-COUNTERS_ATTR_GENERAL(jd_blocks, "%u\n", sdp->sd_jdesc->jd_blocks);
-COUNTERS_ATTR_ATOMIC(reclaim_count, "%u\n");
-COUNTERS_ATTR_SIMPLE(log_wraps, "%llu\n");
-COUNTERS_ATTR_ATOMIC(fh2dentry_misses, "%u\n");
-COUNTERS_ATTR_ATOMIC(reclaimed, "%u\n");
-COUNTERS_ATTR_ATOMIC(log_flush_incore, "%u\n");
-COUNTERS_ATTR_ATOMIC(log_flush_ondisk, "%u\n");
-COUNTERS_ATTR_ATOMIC(glock_nq_calls, "%u\n");
-COUNTERS_ATTR_ATOMIC(glock_dq_calls, "%u\n");
-COUNTERS_ATTR_ATOMIC(glock_prefetch_calls, "%u\n");
-COUNTERS_ATTR_ATOMIC(lm_lock_calls, "%u\n");
-COUNTERS_ATTR_ATOMIC(lm_unlock_calls, "%u\n");
-COUNTERS_ATTR_ATOMIC(lm_callbacks, "%u\n");
-COUNTERS_ATTR_ATOMIC(ops_address, "%u\n");
-COUNTERS_ATTR_ATOMIC(ops_dentry, "%u\n");
-COUNTERS_ATTR_ATOMIC(ops_export, "%u\n");
-COUNTERS_ATTR_ATOMIC(ops_file, "%u\n");
-COUNTERS_ATTR_ATOMIC(ops_inode, "%u\n");
-COUNTERS_ATTR_ATOMIC(ops_super, "%u\n");
-COUNTERS_ATTR_ATOMIC(ops_vm, "%u\n");
+COUNTERS_ATTR(glock_count, "%u\n");
+COUNTERS_ATTR(glock_held_count, "%u\n");
+COUNTERS_ATTR(inode_count, "%u\n");
+COUNTERS_ATTR(reclaimed, "%u\n");
static struct attribute *counters_attrs[] = {
&counters_attr_glock_count.attr,
&counters_attr_glock_held_count.attr,
&counters_attr_inode_count.attr,
- &counters_attr_bufdata_count.attr,
- &counters_attr_unlinked_count.attr,
- &counters_attr_quota_count.attr,
- &counters_attr_log_num_gl.attr,
- &counters_attr_log_num_buf.attr,
- &counters_attr_log_num_revoke.attr,
- &counters_attr_log_num_rg.attr,
- &counters_attr_log_num_databuf.attr,
- &counters_attr_log_blks_free.attr,
- &counters_attr_jd_blocks.attr,
- &counters_attr_reclaim_count.attr,
- &counters_attr_log_wraps.attr,
- &counters_attr_fh2dentry_misses.attr,
&counters_attr_reclaimed.attr,
- &counters_attr_log_flush_incore.attr,
- &counters_attr_log_flush_ondisk.attr,
- &counters_attr_glock_nq_calls.attr,
- &counters_attr_glock_dq_calls.attr,
- &counters_attr_glock_prefetch_calls.attr,
- &counters_attr_lm_lock_calls.attr,
- &counters_attr_lm_unlock_calls.attr,
- &counters_attr_lm_callbacks.attr,
- &counters_attr_ops_address.attr,
- &counters_attr_ops_dentry.attr,
- &counters_attr_ops_export.attr,
- &counters_attr_ops_file.attr,
- &counters_attr_ops_inode.attr,
- &counters_attr_ops_super.attr,
- &counters_attr_ops_vm.attr,
- NULL
+ NULL,
};
/*
static ssize_t quota_scale_show(struct gfs2_sbd *sdp, char *buf)
{
- return sprintf(buf, "%u %u\n", sdp->sd_tune.gt_quota_scale_num,
- sdp->sd_tune.gt_quota_scale_den);
+ return snprintf(buf, PAGE_SIZE, "%u %u\n",
+ sdp->sd_tune.gt_quota_scale_num,
+ sdp->sd_tune.gt_quota_scale_den);
}
static ssize_t quota_scale_store(struct gfs2_sbd *sdp, const char *buf,
#define TUNE_ATTR_2(name, store) \
static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
{ \
- return sprintf(buf, "%u\n", sdp->sd_tune.gt_##name); \
+ return snprintf(buf, PAGE_SIZE, "%u\n", sdp->sd_tune.gt_##name); \
} \
TUNE_ATTR_3(name, name##_show, store)
} \
TUNE_ATTR_2(name, name##_store)
-TUNE_ATTR(ilimit, 0);
-TUNE_ATTR(ilimit_tries, 0);
-TUNE_ATTR(ilimit_min, 0);
TUNE_ATTR(demote_secs, 0);
TUNE_ATTR(incore_log_blocks, 0);
TUNE_ATTR(log_flush_secs, 0);
TUNE_ATTR(max_readahead, 0);
TUNE_ATTR(complain_secs, 0);
TUNE_ATTR(reclaim_limit, 0);
-TUNE_ATTR(prefetch_secs, 0);
TUNE_ATTR(statfs_slow, 0);
TUNE_ATTR(new_files_jdata, 0);
TUNE_ATTR(new_files_directio, 0);
TUNE_ATTR(quota_simul_sync, 1);
TUNE_ATTR(quota_cache_secs, 1);
-TUNE_ATTR(max_atomic_write, 1);
TUNE_ATTR(stall_secs, 1);
-TUNE_ATTR(entries_per_readdir, 1);
-TUNE_ATTR(greedy_default, 1);
-TUNE_ATTR(greedy_quantum, 1);
-TUNE_ATTR(greedy_max, 1);
TUNE_ATTR(statfs_quantum, 1);
TUNE_ATTR_DAEMON(scand_secs, scand_process);
TUNE_ATTR_DAEMON(recoverd_secs, recoverd_process);
TUNE_ATTR_DAEMON(logd_secs, logd_process);
TUNE_ATTR_DAEMON(quotad_secs, quotad_process);
-TUNE_ATTR_DAEMON(inoded_secs, inoded_process);
TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store);
static struct attribute *tune_attrs[] = {
- &tune_attr_ilimit.attr,
- &tune_attr_ilimit_tries.attr,
- &tune_attr_ilimit_min.attr,
&tune_attr_demote_secs.attr,
&tune_attr_incore_log_blocks.attr,
&tune_attr_log_flush_secs.attr,
&tune_attr_max_readahead.attr,
&tune_attr_complain_secs.attr,
&tune_attr_reclaim_limit.attr,
- &tune_attr_prefetch_secs.attr,
&tune_attr_statfs_slow.attr,
&tune_attr_quota_simul_sync.attr,
&tune_attr_quota_cache_secs.attr,
- &tune_attr_max_atomic_write.attr,
&tune_attr_stall_secs.attr,
- &tune_attr_entries_per_readdir.attr,
- &tune_attr_greedy_default.attr,
- &tune_attr_greedy_quantum.attr,
- &tune_attr_greedy_max.attr,
&tune_attr_statfs_quantum.attr,
&tune_attr_scand_secs.attr,
&tune_attr_recoverd_secs.attr,
&tune_attr_logd_secs.attr,
&tune_attr_quotad_secs.attr,
- &tune_attr_inoded_secs.attr,
&tune_attr_quota_scale.attr,
&tune_attr_new_files_jdata.attr,
&tune_attr_new_files_directio.attr,
- NULL
+ NULL,
};
static struct attribute_group lockstruct_group = {
.name = "lockstruct",
- .attrs = lockstruct_attrs
+ .attrs = lockstruct_attrs,
};
static struct attribute_group counters_group = {
.name = "counters",
- .attrs = counters_attrs
+ .attrs = counters_attrs,
};
static struct attribute_group args_group = {
.name = "args",
- .attrs = args_attrs
+ .attrs = args_attrs,
};
static struct attribute_group tune_group = {
.name = "tune",
- .attrs = tune_attrs
+ .attrs = tune_attrs,
};
int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
return 0;
- fail_args:
+fail_args:
sysfs_remove_group(&sdp->sd_kobj, &args_group);
- fail_counters:
+fail_counters:
sysfs_remove_group(&sdp->sd_kobj, &counters_group);
- fail_lockstruct:
+fail_lockstruct:
sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group);
- fail_reg:
+fail_reg:
kobject_unregister(&sdp->sd_kobj);
- fail:
+fail:
+ fs_err(sdp, "error %d adding sysfs files", error);
return error;
}