Commit 61975ead authored by Stephen Lord's avatar Stephen Lord Committed by Stephen Lord

Cleanup xfs and pagebuf sysctl code, use posix initializers to avoid

confusion in the future over which constants apply to which initializers.
parent a406c700
...@@ -14,8 +14,8 @@ for further details. This implementation is on-disk compatible ...@@ -14,8 +14,8 @@ for further details. This implementation is on-disk compatible
with the IRIX version of XFS. with the IRIX version of XFS.
Options Mount Options
======= =============
When mounting an XFS filesystem, the following options are accepted. When mounting an XFS filesystem, the following options are accepted.
...@@ -107,3 +107,66 @@ When mounting an XFS filesystem, the following options are accepted. ...@@ -107,3 +107,66 @@ When mounting an XFS filesystem, the following options are accepted.
Don't check for double mounted file systems using the file system uuid. Don't check for double mounted file systems using the file system uuid.
This is useful to mount LVM snapshot volumes. This is useful to mount LVM snapshot volumes.
sysctls
=======
The following sysctls are available for the XFS filesystem:
fs.xfs.stats_clear (Min: 0 Default: 0 Max: 1)
Setting this to "1" clears accumulated XFS statistics
in /proc/fs/xfs/stat. It then immediately reset to "0".
fs.xfs.sync_interval (Min: HZ Default: 30*HZ Max: 60*HZ)
The interval at which the xfssyncd thread for xfs filesystems
flushes metadata out to disk. This thread will flush log
activity out, and do some processing on unlinked inodes
fs.xfs.error_level (Min: 0 Default: 3 Max: 11)
A volume knob for error reporting when internal errors occur.
This will generate detailed messages & backtraces for filesystem
shutdowns, for example. Current threshold values are:
XFS_ERRLEVEL_OFF: 0
XFS_ERRLEVEL_LOW: 1
XFS_ERRLEVEL_HIGH: 5
fs.xfs.panic_mask (Min: 0 Default: 0 Max: 127)
Causes certain error conditions to call BUG(). Value is a bitmask;
AND together the tags which represent errors which should cause panics:
XFS_NO_PTAG 0LL
XFS_PTAG_IFLUSH 0x0000000000000001LL
XFS_PTAG_LOGRES 0x0000000000000002LL
XFS_PTAG_AILDELETE 0x0000000000000004LL
XFS_PTAG_ERROR_REPORT 0x0000000000000008LL
XFS_PTAG_SHUTDOWN_CORRUPT 0x0000000000000010LL
XFS_PTAG_SHUTDOWN_IOERROR 0x0000000000000020LL
XFS_PTAG_SHUTDOWN_LOGERROR 0x0000000000000040LL
This option is intended for debugging only.
fs.xfs.irix_symlink_mode (Min: 0 Default: 0 Max: 1)
Controls whether symlinks are created with mode 0777 (default)
or whether their mode is affected by the umask (irix mode).
fs.xfs.irix_sgid_inherit (Min: 0 Default: 0 Max: 1)
Controls files created in SGID directories.
If the group ID of the new file does not match the effective group
ID or one of the supplementary group IDs of the parent dir, the
ISGID bit is cleared if the irix_sgid_inherit compatibility sysctl
is set.
fs.xfs.restrict_chown (Min: 0 Default: 1 Max: 1)
Controls whether unprivileged users can use chown to "give away"
a file to another user.
vm.pagebuf.stats_clear (Min: 0 Default: 0 Max: 1)
Setting this to "1" clears accumulated pagebuf statistics
in /proc/fs/pagebuf/stat. It then immediately reset to "0".
vm.pagebuf.flush_age (Min: 1*HZ Default: 15*HZ Max: 300*HZ)
The age at which dirty metadata buffers are flushed to disk
vm.pagebuf.flush_int (Min: HZ/2 Default: HZ Max: 30*HZ)
The interval at which the list of dirty metadata buffers is
scanned.
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "xfs.h" #include "xfs.h"
#include "xfs_bmap_btree.h" #include "xfs_bmap_btree.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_rw.h"
/* /*
* System memory size - used to scale certain data structures in XFS. * System memory size - used to scale certain data structures in XFS.
...@@ -48,7 +49,18 @@ unsigned long xfs_physmem; ...@@ -48,7 +49,18 @@ unsigned long xfs_physmem;
* Tunable XFS parameters. xfs_params is required even when CONFIG_SYSCTL=n, * Tunable XFS parameters. xfs_params is required even when CONFIG_SYSCTL=n,
* other XFS code uses these values. * other XFS code uses these values.
*/ */
xfs_param_t xfs_params = { 0, 1, 0, 0, 3, 30 * HZ, 0 };
xfs_param_t xfs_params = {
/* MIN DFLT MAX */
restrict_chown: { 0, 1, 1 },
sgid_inherit: { 0, 0, 1 },
symlink_mode: { 0, 0, 1 },
panic_mask: { 0, 0, 127 },
error_level: { 0, 3, 11 },
sync_interval: { HZ, 30*HZ, 60*HZ },
stats_clear: { 0, 0, 1 },
};
/* /*
* Global system credential structure. * Global system credential structure.
......
...@@ -87,11 +87,15 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh) ...@@ -87,11 +87,15 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
bh->b_end_io = linvfs_unwritten_done; bh->b_end_io = linvfs_unwritten_done;
} }
#define restricted_chown xfs_params.restrict_chown #define xfs_refcache_size xfs_params.refcache_size.val
#define irix_sgid_inherit xfs_params.sgid_inherit #define xfs_refcache_purge_count xfs_params.refcache_purge.val
#define irix_symlink_mode xfs_params.symlink_mode #define restricted_chown xfs_params.restrict_chown.val
#define xfs_panic_mask xfs_params.panic_mask #define irix_sgid_inherit xfs_params.sgid_inherit.val
#define xfs_error_level xfs_params.error_level #define irix_symlink_mode xfs_params.symlink_mode.val
#define xfs_panic_mask xfs_params.panic_mask.val
#define xfs_error_level xfs_params.error_level.val
#define xfs_syncd_interval xfs_params.sync_interval.val
#define xfs_stats_clear xfs_params.stats_clear.val
#define NBPP PAGE_SIZE #define NBPP PAGE_SIZE
#define DPPSHFT (PAGE_SHIFT - 9) #define DPPSHFT (PAGE_SHIFT - 9)
......
...@@ -401,7 +401,7 @@ syncd(void *arg) ...@@ -401,7 +401,7 @@ syncd(void *arg)
for (;;) { for (;;) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(xfs_params.sync_interval); schedule_timeout(xfs_syncd_interval);
/* swsusp */ /* swsusp */
if (current->flags & PF_FREEZE) if (current->flags & PF_FREEZE)
refrigerator(PF_IOTHREAD); refrigerator(PF_IOTHREAD);
......
...@@ -36,9 +36,6 @@ ...@@ -36,9 +36,6 @@
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
STATIC ulong xfs_min[XFS_PARAM] = { 0, 0, 0, 0, 0, HZ, 0 };
STATIC ulong xfs_max[XFS_PARAM] = { 1, 1, 1, 127, 3, HZ * 60, 1 };
static struct ctl_table_header *xfs_table_header; static struct ctl_table_header *xfs_table_header;
...@@ -62,7 +59,7 @@ xfs_stats_clear_proc_handler( ...@@ -62,7 +59,7 @@ xfs_stats_clear_proc_handler(
vn_active = xfsstats.vn_active; vn_active = xfsstats.vn_active;
memset(&xfsstats, 0, sizeof(xfsstats)); memset(&xfsstats, 0, sizeof(xfsstats));
xfsstats.vn_active = vn_active; xfsstats.vn_active = vn_active;
xfs_params.stats_clear = 0; xfs_stats_clear = 0;
} }
return ret; return ret;
...@@ -70,35 +67,42 @@ xfs_stats_clear_proc_handler( ...@@ -70,35 +67,42 @@ xfs_stats_clear_proc_handler(
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
STATIC ctl_table xfs_table[] = { STATIC ctl_table xfs_table[] = {
{XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown, {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax, sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax,
&sysctl_intvec, NULL, &xfs_min[0], &xfs_max[0]}, &sysctl_intvec, NULL,
&xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
{XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit, {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax, sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax,
&sysctl_intvec, NULL, &xfs_min[1], &xfs_max[1]}, &sysctl_intvec, NULL,
&xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max},
{XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode, {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax, sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax,
&sysctl_intvec, NULL, &xfs_min[2], &xfs_max[2]}, &sysctl_intvec, NULL,
&xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
{XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask, {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax, sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax,
&sysctl_intvec, NULL, &xfs_min[3], &xfs_max[3]}, &sysctl_intvec, NULL,
&xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
{XFS_ERRLEVEL, "error_level", &xfs_params.error_level, {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax, sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax,
&sysctl_intvec, NULL, &xfs_min[4], &xfs_max[4]}, &sysctl_intvec, NULL,
&xfs_params.error_level.min, &xfs_params.error_level.max},
{XFS_SYNC_INTERVAL, "sync_interval", &xfs_params.sync_interval, {XFS_SYNC_INTERVAL, "sync_interval", &xfs_params.sync_interval.val,
sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax, sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax,
&sysctl_intvec, NULL, &xfs_min[5], &xfs_max[5]}, &sysctl_intvec, NULL,
&xfs_params.sync_interval.min, &xfs_params.sync_interval.max},
/* please keep this the last entry */ /* please keep this the last entry */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
{XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear, {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
sizeof(ulong), 0644, NULL, &xfs_stats_clear_proc_handler, sizeof(ulong), 0644, NULL, &xfs_stats_clear_proc_handler,
&sysctl_intvec, NULL, &xfs_min[6], &xfs_max[6]}, &sysctl_intvec, NULL,
&xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
{0} {0}
......
...@@ -39,17 +39,22 @@ ...@@ -39,17 +39,22 @@
* Tunable xfs parameters * Tunable xfs parameters
*/ */
#define XFS_PARAM (sizeof(struct xfs_param) / sizeof(ulong)) typedef struct xfs_sysctl_val {
ulong min;
ulong val;
ulong max;
} xfs_sysctl_val_t;
typedef struct xfs_param { typedef struct xfs_param {
ulong restrict_chown; /* Root/non-root can give away files. */ xfs_sysctl_val_t restrict_chown;/* Root/non-root can give away files.*/
ulong sgid_inherit; /* Inherit ISGID bit if process' GID is */ xfs_sysctl_val_t sgid_inherit; /* Inherit ISGID bit if process' GID
/* not a member of the parent dir GID. */ * is not a member of the parent dir
ulong symlink_mode; /* Symlink creat mode affected by umask. */ * GID */
ulong panic_mask; /* bitmask to specify panics on errors. */ xfs_sysctl_val_t symlink_mode; /* Link creat mode affected by umask */
ulong error_level; /* Degree of reporting for internal probs*/ xfs_sysctl_val_t panic_mask; /* bitmask to cause panic on errors. */
ulong sync_interval; /* time between sync calls */ xfs_sysctl_val_t error_level; /* Degree of reporting for problems */
ulong stats_clear; /* Reset all XFS statistics to zero. */ xfs_sysctl_val_t sync_interval; /* time between sync calls */
xfs_sysctl_val_t stats_clear; /* Reset all XFS statistics to zero. */
} xfs_param_t; } xfs_param_t;
/* /*
......
...@@ -92,7 +92,7 @@ pb_trace_func( ...@@ -92,7 +92,7 @@ pb_trace_func(
int j; int j;
unsigned long flags; unsigned long flags;
if (!pb_params.p_un.debug) return; if (!pb_params.debug.val) return;
if (ra == NULL) ra = (void *)__builtin_return_address(0); if (ra == NULL) ra = (void *)__builtin_return_address(0);
...@@ -129,10 +129,13 @@ STATIC struct workqueue_struct *pagebuf_dataio_workqueue; ...@@ -129,10 +129,13 @@ STATIC struct workqueue_struct *pagebuf_dataio_workqueue;
* /proc/sys/vm/pagebuf * /proc/sys/vm/pagebuf
*/ */
unsigned long pagebuf_min[P_PARAM] = { HZ/2, 1*HZ, 0, 0 }; pagebuf_param_t pb_params = {
unsigned long pagebuf_max[P_PARAM] = { HZ*30, HZ*300, 1, 1 }; /* MIN DFLT MAX */
flush_interval: { HZ/2, HZ, 30*HZ },
pagebuf_param_t pb_params = {{ HZ, 15 * HZ, 0, 0 }}; age_buffer: { 1*HZ, 15*HZ, 300*HZ },
stats_clear: { 0, 0, 1 },
debug: { 0, 0, 1 },
};
/* /*
* Pagebuf statistics variables * Pagebuf statistics variables
...@@ -1556,7 +1559,7 @@ pagebuf_delwri_queue( ...@@ -1556,7 +1559,7 @@ pagebuf_delwri_queue(
} }
list_add_tail(&pb->pb_list, &pbd_delwrite_queue); list_add_tail(&pb->pb_list, &pbd_delwrite_queue);
pb->pb_flushtime = jiffies + pb_params.p_un.age_buffer; pb->pb_flushtime = jiffies + pb_params.age_buffer.val;
spin_unlock(&pbd_delwrite_lock); spin_unlock(&pbd_delwrite_lock);
if (unlock && (pb->pb_flags & _PBF_LOCKABLE)) { if (unlock && (pb->pb_flags & _PBF_LOCKABLE)) {
...@@ -1621,7 +1624,7 @@ pagebuf_daemon( ...@@ -1621,7 +1624,7 @@ pagebuf_daemon(
if (pbd_active == 1) { if (pbd_active == 1) {
mod_timer(&pb_daemon_timer, mod_timer(&pb_daemon_timer,
jiffies + pb_params.p_un.flush_interval); jiffies + pb_params.flush_interval.val);
interruptible_sleep_on(&pbd_waitq); interruptible_sleep_on(&pbd_waitq);
} }
...@@ -1824,7 +1827,7 @@ pb_stats_clear_handler( ...@@ -1824,7 +1827,7 @@ pb_stats_clear_handler(
if (!ret && write && *valp) { if (!ret && write && *valp) {
printk("XFS Clearing pbstats\n"); printk("XFS Clearing pbstats\n");
memset(&pbstats, 0, sizeof(pbstats)); memset(&pbstats, 0, sizeof(pbstats));
pb_params.p_un.stats_clear = 0; pb_params.stats_clear.val = 0;
} }
return ret; return ret;
...@@ -1833,22 +1836,26 @@ pb_stats_clear_handler( ...@@ -1833,22 +1836,26 @@ pb_stats_clear_handler(
STATIC struct ctl_table_header *pagebuf_table_header; STATIC struct ctl_table_header *pagebuf_table_header;
STATIC ctl_table pagebuf_table[] = { STATIC ctl_table pagebuf_table[] = {
{PB_FLUSH_INT, "flush_int", &pb_params.data[0], {PB_FLUSH_INT, "flush_int", &pb_params.flush_interval.val,
sizeof(ulong), 0644, NULL, &proc_doulongvec_ms_jiffies_minmax, sizeof(ulong), 0644, NULL, &proc_doulongvec_ms_jiffies_minmax,
&sysctl_intvec, NULL, &pagebuf_min[0], &pagebuf_max[0]}, &sysctl_intvec, NULL,
&pb_params.flush_interval.min, &pb_params.flush_interval.max},
{PB_FLUSH_AGE, "flush_age", &pb_params.data[1], {PB_FLUSH_AGE, "flush_age", &pb_params.age_buffer.val,
sizeof(ulong), 0644, NULL, &proc_doulongvec_ms_jiffies_minmax, sizeof(ulong), 0644, NULL, &proc_doulongvec_ms_jiffies_minmax,
&sysctl_intvec, NULL, &pagebuf_min[1], &pagebuf_max[1]}, &sysctl_intvec, NULL,
&pb_params.age_buffer.min, &pb_params.age_buffer.max},
{PB_STATS_CLEAR, "stats_clear", &pb_params.data[2], {PB_STATS_CLEAR, "stats_clear", &pb_params.stats_clear.val,
sizeof(ulong), 0644, NULL, &pb_stats_clear_handler, sizeof(ulong), 0644, NULL, &pb_stats_clear_handler,
&sysctl_intvec, NULL, &pagebuf_min[2], &pagebuf_max[2]}, &sysctl_intvec, NULL,
&pb_params.stats_clear.min, &pb_params.stats_clear.max},
#ifdef PAGEBUF_TRACE #ifdef PAGEBUF_TRACE
{PB_DEBUG, "debug", &pb_params.data[3], {PB_DEBUG, "debug", &pb_params.debug.val,
sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax, sizeof(ulong), 0644, NULL, &proc_doulongvec_minmax,
&sysctl_intvec, NULL, &pagebuf_min[3], &pagebuf_max[3]}, &sysctl_intvec, NULL,
&pb_params.debug.min, &pb_params.debug.max},
#endif #endif
{0} {0}
}; };
......
...@@ -85,18 +85,19 @@ struct pagebuf_trace_buf { ...@@ -85,18 +85,19 @@ struct pagebuf_trace_buf {
* Tunable pagebuf parameters * Tunable pagebuf parameters
*/ */
#define P_PARAM 4 typedef struct pb_sysctl_val {
ulong min;
typedef union pagebuf_param { ulong val;
struct { ulong max;
ulong flush_interval; /* interval between runs of the } pb_sysctl_val_t;
typedef struct pagebuf_param {
pb_sysctl_val_t flush_interval; /* interval between runs of the
* delwri flush daemon. */ * delwri flush daemon. */
ulong age_buffer; /* time for buffer to age before pb_sysctl_val_t age_buffer; /* time for buffer to age before
* we flush it. */ * we flush it. */
ulong debug; /* debug tracing on or off */ pb_sysctl_val_t stats_clear; /* clear the pagebuf stats */
ulong stats_clear; /* clear the pagebuf stats */ pb_sysctl_val_t debug; /* debug tracing on or off */
} p_un;
ulong data[P_PARAM];
} pagebuf_param_t; } pagebuf_param_t;
enum { enum {
......
...@@ -96,9 +96,6 @@ xfs_init(void) ...@@ -96,9 +96,6 @@ xfs_init(void)
#endif /* DEBUG */ #endif /* DEBUG */
#ifdef XFS_DABUF_DEBUG #ifdef XFS_DABUF_DEBUG
extern lock_t xfs_dabuf_global_lock; extern lock_t xfs_dabuf_global_lock;
#endif
#ifdef XFS_DABUF_DEBUG
spinlock_init(&xfs_dabuf_global_lock, "xfsda"); spinlock_init(&xfs_dabuf_global_lock, "xfsda");
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment