Lines Matching +full:mode +full:- +full:capable

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
4 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
41 return a->show ? a->show(sdp, buf) : 0; in gfs2_attr_show()
49 return a->store ? a->store(sdp, buf, len) : len; in gfs2_attr_store()
63 MAJOR(sdp->sd_vfs->s_dev), MINOR(sdp->sd_vfs->s_dev)); in id_show()
68 unsigned long f = sdp->sd_flags; in status_show()
107 (sdp->sd_jdesc ? sdp->sd_jdesc->jd_jid : 0), in status_show()
108 (sdp->sd_args.ar_spectator ? 1 : 0), in status_show()
114 (sb_rdonly(sdp->sd_vfs) ? 1 : 0), in status_show()
125 sdp->sd_log_error, in status_show()
126 rwsem_is_locked(&sdp->sd_log_flush_lock), in status_show()
127 sdp->sd_log_num_revoke, in status_show()
128 atomic_read(&sdp->sd_log_in_flight), in status_show()
129 atomic_read(&sdp->sd_log_blks_needed), in status_show()
130 atomic_read(&sdp->sd_log_blks_free), in status_show()
131 sdp->sd_log_flush_head, in status_show()
132 sdp->sd_log_flush_tail, in status_show()
133 sdp->sd_log_blks_reserved, in status_show()
134 atomic_read(&sdp->sd_log_revokes_available), in status_show()
135 atomic_read(&sdp->sd_log_pinned), in status_show()
136 atomic_read(&sdp->sd_log_thresh1), in status_show()
137 atomic_read(&sdp->sd_log_thresh2)); in status_show()
143 return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname); in fsname_show()
148 struct super_block *s = sdp->sd_vfs; in uuid_show()
151 if (uuid_is_null(&s->s_uuid)) in uuid_show()
153 return snprintf(buf, PAGE_SIZE, "%pUB\n", &s->s_uuid); in uuid_show()
158 struct super_block *sb = sdp->sd_vfs; in freeze_show()
159 int frozen = (sb->s_writers.frozen == SB_UNFROZEN) ? 0 : 1; in freeze_show()
172 if (!capable(CAP_SYS_ADMIN)) in freeze_store()
173 return -EPERM; in freeze_store()
177 error = thaw_super(sdp->sd_vfs, FREEZE_HOLDER_USERSPACE); in freeze_store()
180 error = freeze_super(sdp->sd_vfs, FREEZE_HOLDER_USERSPACE); in freeze_store()
183 return -EINVAL; in freeze_store()
204 if (!capable(CAP_SYS_ADMIN)) in withdraw_store()
205 return -EPERM; in withdraw_store()
212 return -EINVAL; in withdraw_store()
225 if (!capable(CAP_SYS_ADMIN)) in statfs_sync_store()
226 return -EPERM; in statfs_sync_store()
233 return -EINVAL; in statfs_sync_store()
235 gfs2_statfs_sync(sdp->sd_vfs, 0); in statfs_sync_store()
244 if (!capable(CAP_SYS_ADMIN)) in quota_sync_store()
245 return -EPERM; in quota_sync_store()
252 return -EINVAL; in quota_sync_store()
254 gfs2_quota_sync(sdp->sd_vfs, 0); in quota_sync_store()
265 if (!capable(CAP_SYS_ADMIN)) in quota_refresh_user_store()
266 return -EPERM; in quota_refresh_user_store()
274 return -EINVAL; in quota_refresh_user_store()
287 if (!capable(CAP_SYS_ADMIN)) in quota_refresh_group_store()
288 return -EPERM; in quota_refresh_group_store()
296 return -EINVAL; in quota_refresh_group_store()
309 char mode[16]; in demote_rq_store() local
312 if (!capable(CAP_SYS_ADMIN)) in demote_rq_store()
313 return -EPERM; in demote_rq_store()
316 mode); in demote_rq_store()
318 return -EINVAL; in demote_rq_store()
320 if (strcmp(mode, "EX") == 0) in demote_rq_store()
322 else if ((strcmp(mode, "CW") == 0) || (strcmp(mode, "DF") == 0)) in demote_rq_store()
324 else if ((strcmp(mode, "PR") == 0) || (strcmp(mode, "SH") == 0)) in demote_rq_store()
327 return -EINVAL; in demote_rq_store()
330 return -EINVAL; in demote_rq_store()
336 return -EINVAL; in demote_rq_store()
337 if (!test_and_set_bit(SDF_DEMOTE, &sdp->sd_flags)) in demote_rq_store()
348 #define GFS2_ATTR(name, mode, show, store) \ argument
349 static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)
383 complete(&sdp->sd_kobj_unregister); in gfs2_sbd_release()
399 const struct lm_lockops *ops = sdp->sd_lockstruct.ls_ops; in proto_name_show()
400 return sprintf(buf, "%s\n", ops->lm_proto_name); in proto_name_show()
405 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in block_show()
409 if (test_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags)) in block_show()
417 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in block_store()
425 set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); in block_store()
427 clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); in block_store()
431 return -EINVAL; in block_store()
438 int val = completion_done(&sdp->sd_wdack) ? 1 : 0; in wdack_show()
452 !strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm")) in wdack_store()
453 complete(&sdp->sd_wdack); in wdack_store()
455 return -EINVAL; in wdack_store()
461 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in lkfirst_show()
462 return sprintf(buf, "%d\n", ls->ls_first); in lkfirst_show()
472 return -EINVAL; in lkfirst_store()
473 rv = wait_for_completion_killable(&sdp->sd_locking_init); in lkfirst_store()
476 spin_lock(&sdp->sd_jindex_spin); in lkfirst_store()
477 rv = -EBUSY; in lkfirst_store()
478 if (test_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0) in lkfirst_store()
480 rv = -EINVAL; in lkfirst_store()
481 if (sdp->sd_args.ar_spectator) in lkfirst_store()
483 if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL) in lkfirst_store()
485 sdp->sd_lockstruct.ls_first = first; in lkfirst_store()
488 spin_unlock(&sdp->sd_jindex_spin); in lkfirst_store()
494 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in first_done_show()
495 return sprintf(buf, "%d\n", !!test_bit(DFL_FIRST_MOUNT_DONE, &ls->ls_recover_flags)); in first_done_show()
504 wait_for_completion(&sdp->sd_journal_ready); in gfs2_recover_set()
506 spin_lock(&sdp->sd_jindex_spin); in gfs2_recover_set()
507 rv = -EBUSY; in gfs2_recover_set()
515 if (!sdp->sd_jdesc) in gfs2_recover_set()
517 if (sdp->sd_jdesc->jd_jid == jid && !sdp->sd_args.ar_spectator) in gfs2_recover_set()
519 rv = -ENOENT; in gfs2_recover_set()
520 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { in gfs2_recover_set()
521 if (jd->jd_jid != jid && !sdp->sd_args.ar_spectator) in gfs2_recover_set()
527 spin_unlock(&sdp->sd_jindex_spin); in gfs2_recover_set()
538 return -EINVAL; in recover_store()
540 if (test_bit(SDF_NORECOVERY, &sdp->sd_flags)) { in recover_store()
541 rv = -ESHUTDOWN; in recover_store()
552 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in recover_done_show()
553 return sprintf(buf, "%d\n", ls->ls_recover_jid_done); in recover_done_show()
558 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in recover_status_show()
559 return sprintf(buf, "%d\n", ls->ls_recover_jid_status); in recover_status_show()
564 return sprintf(buf, "%d\n", sdp->sd_lockstruct.ls_jid); in jid_show()
574 return -EINVAL; in jid_store()
575 rv = wait_for_completion_killable(&sdp->sd_locking_init); in jid_store()
578 spin_lock(&sdp->sd_jindex_spin); in jid_store()
579 rv = -EINVAL; in jid_store()
580 if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL) in jid_store()
582 rv = -EBUSY; in jid_store()
583 if (test_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0) in jid_store()
586 if (sdp->sd_args.ar_spectator && jid > 0) in jid_store()
587 rv = jid = -EINVAL; in jid_store()
588 sdp->sd_lockstruct.ls_jid = jid; in jid_store()
589 clear_bit(SDF_NOJOURNALID, &sdp->sd_flags); in jid_store()
591 wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID); in jid_store()
593 spin_unlock(&sdp->sd_jindex_spin); in jid_store()
630 sdp->sd_tune.gt_quota_scale_num, in quota_scale_show()
631 sdp->sd_tune.gt_quota_scale_den); in quota_scale_show()
637 struct gfs2_tune *gt = &sdp->sd_tune; in quota_scale_store()
640 if (!capable(CAP_SYS_ADMIN)) in quota_scale_store()
641 return -EPERM; in quota_scale_store()
644 return -EINVAL; in quota_scale_store()
646 spin_lock(&gt->gt_spin); in quota_scale_store()
647 gt->gt_quota_scale_num = x; in quota_scale_store()
648 gt->gt_quota_scale_den = y; in quota_scale_store()
649 spin_unlock(&gt->gt_spin); in quota_scale_store()
656 struct gfs2_tune *gt = &sdp->sd_tune; in tune_set()
660 if (!capable(CAP_SYS_ADMIN)) in tune_set()
661 return -EPERM; in tune_set()
668 return -EINVAL; in tune_set()
670 spin_lock(&gt->gt_spin); in tune_set()
672 spin_unlock(&gt->gt_spin); in tune_set()
682 return snprintf(buf, PAGE_SIZE, "%u\n", sdp->sd_tune.gt_##name); \
689 return tune_set(sdp, &sdp->sd_tune.gt_##name, check_zero, buf, len); \
726 struct super_block *sb = sdp->sd_vfs; in gfs2_sys_fs_add()
733 sprintf(spectator, "SPECTATOR=%d", sdp->sd_args.ar_spectator ? 1 : 0); in gfs2_sys_fs_add()
735 init_completion(&sdp->sd_kobj_unregister); in gfs2_sys_fs_add()
736 sdp->sd_kobj.kset = gfs2_kset; in gfs2_sys_fs_add()
737 error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL, in gfs2_sys_fs_add()
738 "%s", sdp->sd_table_name); in gfs2_sys_fs_add()
742 error = sysfs_create_group(&sdp->sd_kobj, &tune_group); in gfs2_sys_fs_add()
746 error = sysfs_create_group(&sdp->sd_kobj, &lock_module_group); in gfs2_sys_fs_add()
750 error = sysfs_create_link(&sdp->sd_kobj, in gfs2_sys_fs_add()
751 &disk_to_dev(sb->s_bdev->bd_disk)->kobj, in gfs2_sys_fs_add()
756 kobject_uevent_env(&sdp->sd_kobj, KOBJ_ADD, envp); in gfs2_sys_fs_add()
760 sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); in gfs2_sys_fs_add()
762 sysfs_remove_group(&sdp->sd_kobj, &tune_group); in gfs2_sys_fs_add()
765 kobject_put(&sdp->sd_kobj); in gfs2_sys_fs_add()
766 wait_for_completion(&sdp->sd_kobj_unregister); in gfs2_sys_fs_add()
767 sb->s_fs_info = NULL; in gfs2_sys_fs_add()
773 sysfs_remove_link(&sdp->sd_kobj, "device"); in gfs2_sys_fs_del()
774 sysfs_remove_group(&sdp->sd_kobj, &tune_group); in gfs2_sys_fs_del()
775 sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); in gfs2_sys_fs_del()
776 kobject_put(&sdp->sd_kobj); in gfs2_sys_fs_del()
777 wait_for_completion(&sdp->sd_kobj_unregister); in gfs2_sys_fs_del()
783 const struct super_block *s = sdp->sd_vfs; in gfs2_uevent()
785 add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name); in gfs2_uevent()
786 add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); in gfs2_uevent()
787 if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags)) in gfs2_uevent()
788 add_uevent_var(env, "JOURNALID=%d", sdp->sd_lockstruct.ls_jid); in gfs2_uevent()
789 if (!uuid_is_null(&s->s_uuid)) in gfs2_uevent()
790 add_uevent_var(env, "UUID=%pUB", &s->s_uuid); in gfs2_uevent()
802 return -ENOMEM; in gfs2_sys_init()