sys.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
  4. *
  5. * This copyrighted material is made available to anyone wishing to use,
  6. * modify, copy, or redistribute it subject to the terms and conditions
  7. * of the GNU General Public License version 2.
  8. */
  9. #include <linux/sched.h>
  10. #include <linux/spinlock.h>
  11. #include <linux/completion.h>
  12. #include <linux/buffer_head.h>
  13. #include <linux/module.h>
  14. #include <linux/kobject.h>
  15. #include <asm/uaccess.h>
  16. #include <linux/gfs2_ondisk.h>
  17. #include <linux/genhd.h>
  18. #include "gfs2.h"
  19. #include "incore.h"
  20. #include "sys.h"
  21. #include "super.h"
  22. #include "glock.h"
  23. #include "quota.h"
  24. #include "util.h"
  25. #include "glops.h"
  26. struct gfs2_attr {
  27. struct attribute attr;
  28. ssize_t (*show)(struct gfs2_sbd *, char *);
  29. ssize_t (*store)(struct gfs2_sbd *, const char *, size_t);
  30. };
  31. static ssize_t gfs2_attr_show(struct kobject *kobj, struct attribute *attr,
  32. char *buf)
  33. {
  34. struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
  35. struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
  36. return a->show ? a->show(sdp, buf) : 0;
  37. }
  38. static ssize_t gfs2_attr_store(struct kobject *kobj, struct attribute *attr,
  39. const char *buf, size_t len)
  40. {
  41. struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
  42. struct gfs2_attr *a = container_of(attr, struct gfs2_attr, attr);
  43. return a->store ? a->store(sdp, buf, len) : len;
  44. }
  45. static const struct sysfs_ops gfs2_attr_ops = {
  46. .show = gfs2_attr_show,
  47. .store = gfs2_attr_store,
  48. };
  49. static struct kset *gfs2_kset;
  50. static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
  51. {
  52. return snprintf(buf, PAGE_SIZE, "%u:%u\n",
  53. MAJOR(sdp->sd_vfs->s_dev), MINOR(sdp->sd_vfs->s_dev));
  54. }
  55. static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf)
  56. {
  57. return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname);
  58. }
  59. static int gfs2_uuid_valid(const u8 *uuid)
  60. {
  61. int i;
  62. for (i = 0; i < 16; i++) {
  63. if (uuid[i])
  64. return 1;
  65. }
  66. return 0;
  67. }
  68. static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf)
  69. {
  70. const u8 *uuid = sdp->sd_sb.sb_uuid;
  71. buf[0] = '\0';
  72. if (!gfs2_uuid_valid(uuid))
  73. return 0;
  74. return snprintf(buf, PAGE_SIZE, "%pUB\n", uuid);
  75. }
  76. static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
  77. {
  78. unsigned int count;
  79. mutex_lock(&sdp->sd_freeze_lock);
  80. count = sdp->sd_freeze_count;
  81. mutex_unlock(&sdp->sd_freeze_lock);
  82. return snprintf(buf, PAGE_SIZE, "%u\n", count);
  83. }
  84. static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
  85. {
  86. ssize_t ret = len;
  87. int error = 0;
  88. int n = simple_strtol(buf, NULL, 0);
  89. if (!capable(CAP_SYS_ADMIN))
  90. return -EACCES;
  91. switch (n) {
  92. case 0:
  93. gfs2_unfreeze_fs(sdp);
  94. break;
  95. case 1:
  96. error = gfs2_freeze_fs(sdp);
  97. break;
  98. default:
  99. ret = -EINVAL;
  100. }
  101. if (error)
  102. fs_warn(sdp, "freeze %d error %d", n, error);
  103. return ret;
  104. }
  105. static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)
  106. {
  107. unsigned int b = test_bit(SDF_SHUTDOWN, &sdp->sd_flags);
  108. return snprintf(buf, PAGE_SIZE, "%u\n", b);
  109. }
  110. static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
  111. {
  112. if (!capable(CAP_SYS_ADMIN))
  113. return -EACCES;
  114. if (simple_strtol(buf, NULL, 0) != 1)
  115. return -EINVAL;
  116. gfs2_lm_withdraw(sdp,
  117. "GFS2: fsid=%s: withdrawing from cluster at user's request\n",
  118. sdp->sd_fsname);
  119. return len;
  120. }
  121. static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
  122. size_t len)
  123. {
  124. if (!capable(CAP_SYS_ADMIN))
  125. return -EACCES;
  126. if (simple_strtol(buf, NULL, 0) != 1)
  127. return -EINVAL;
  128. gfs2_statfs_sync(sdp->sd_vfs, 0);
  129. return len;
  130. }
  131. static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
  132. size_t len)
  133. {
  134. if (!capable(CAP_SYS_ADMIN))
  135. return -EACCES;
  136. if (simple_strtol(buf, NULL, 0) != 1)
  137. return -EINVAL;
  138. gfs2_quota_sync(sdp->sd_vfs, 0, 1);
  139. return len;
  140. }
  141. static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
  142. size_t len)
  143. {
  144. int error;
  145. u32 id;
  146. if (!capable(CAP_SYS_ADMIN))
  147. return -EACCES;
  148. id = simple_strtoul(buf, NULL, 0);
  149. error = gfs2_quota_refresh(sdp, 1, id);
  150. return error ? error : len;
  151. }
  152. static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
  153. size_t len)
  154. {
  155. int error;
  156. u32 id;
  157. if (!capable(CAP_SYS_ADMIN))
  158. return -EACCES;
  159. id = simple_strtoul(buf, NULL, 0);
  160. error = gfs2_quota_refresh(sdp, 0, id);
  161. return error ? error : len;
  162. }
  163. static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
  164. {
  165. struct gfs2_glock *gl;
  166. const struct gfs2_glock_operations *glops;
  167. unsigned int glmode;
  168. unsigned int gltype;
  169. unsigned long long glnum;
  170. char mode[16];
  171. int rv;
  172. if (!capable(CAP_SYS_ADMIN))
  173. return -EACCES;
  174. rv = sscanf(buf, "%u:%llu %15s", &gltype, &glnum,
  175. mode);
  176. if (rv != 3)
  177. return -EINVAL;
  178. if (strcmp(mode, "EX") == 0)
  179. glmode = LM_ST_UNLOCKED;
  180. else if ((strcmp(mode, "CW") == 0) || (strcmp(mode, "DF") == 0))
  181. glmode = LM_ST_DEFERRED;
  182. else if ((strcmp(mode, "PR") == 0) || (strcmp(mode, "SH") == 0))
  183. glmode = LM_ST_SHARED;
  184. else
  185. return -EINVAL;
  186. if (gltype > LM_TYPE_JOURNAL)
  187. return -EINVAL;
  188. glops = gfs2_glops_list[gltype];
  189. if (glops == NULL)
  190. return -EINVAL;
  191. if (!test_and_set_bit(SDF_DEMOTE, &sdp->sd_flags))
  192. fs_info(sdp, "demote interface used\n");
  193. rv = gfs2_glock_get(sdp, glnum, glops, 0, &gl);
  194. if (rv)
  195. return rv;
  196. gfs2_glock_cb(gl, glmode);
  197. gfs2_glock_put(gl);
  198. return len;
  199. }
  200. #define GFS2_ATTR(name, mode, show, store) \
  201. static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)
  202. GFS2_ATTR(id, 0444, id_show, NULL);
  203. GFS2_ATTR(fsname, 0444, fsname_show, NULL);
  204. GFS2_ATTR(uuid, 0444, uuid_show, NULL);
  205. GFS2_ATTR(freeze, 0644, freeze_show, freeze_store);
  206. GFS2_ATTR(withdraw, 0644, withdraw_show, withdraw_store);
  207. GFS2_ATTR(statfs_sync, 0200, NULL, statfs_sync_store);
  208. GFS2_ATTR(quota_sync, 0200, NULL, quota_sync_store);
  209. GFS2_ATTR(quota_refresh_user, 0200, NULL, quota_refresh_user_store);
  210. GFS2_ATTR(quota_refresh_group, 0200, NULL, quota_refresh_group_store);
  211. GFS2_ATTR(demote_rq, 0200, NULL, demote_rq_store);
  212. static struct attribute *gfs2_attrs[] = {
  213. &gfs2_attr_id.attr,
  214. &gfs2_attr_fsname.attr,
  215. &gfs2_attr_uuid.attr,
  216. &gfs2_attr_freeze.attr,
  217. &gfs2_attr_withdraw.attr,
  218. &gfs2_attr_statfs_sync.attr,
  219. &gfs2_attr_quota_sync.attr,
  220. &gfs2_attr_quota_refresh_user.attr,
  221. &gfs2_attr_quota_refresh_group.attr,
  222. &gfs2_attr_demote_rq.attr,
  223. NULL,
  224. };
  225. static struct kobj_type gfs2_ktype = {
  226. .default_attrs = gfs2_attrs,
  227. .sysfs_ops = &gfs2_attr_ops,
  228. };
  229. /*
  230. * lock_module. Originally from lock_dlm
  231. */
  232. static ssize_t proto_name_show(struct gfs2_sbd *sdp, char *buf)
  233. {
  234. const struct lm_lockops *ops = sdp->sd_lockstruct.ls_ops;
  235. return sprintf(buf, "%s\n", ops->lm_proto_name);
  236. }
  237. static ssize_t block_show(struct gfs2_sbd *sdp, char *buf)
  238. {
  239. struct lm_lockstruct *ls = &sdp->sd_lockstruct;
  240. ssize_t ret;
  241. int val = 0;
  242. if (test_bit(DFL_BLOCK_LOCKS, &ls->ls_flags))
  243. val = 1;
  244. ret = sprintf(buf, "%d\n", val);
  245. return ret;
  246. }
  247. static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
  248. {
  249. struct lm_lockstruct *ls = &sdp->sd_lockstruct;
  250. ssize_t ret = len;
  251. int val;
  252. val = simple_strtol(buf, NULL, 0);
  253. if (val == 1)
  254. set_bit(DFL_BLOCK_LOCKS, &ls->ls_flags);
  255. else if (val == 0) {
  256. clear_bit(DFL_BLOCK_LOCKS, &ls->ls_flags);
  257. smp_mb__after_clear_bit();
  258. gfs2_glock_thaw(sdp);
  259. } else {
  260. ret = -EINVAL;
  261. }
  262. return ret;
  263. }
  264. static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf)
  265. {
  266. struct lm_lockstruct *ls = &sdp->sd_lockstruct;
  267. return sprintf(buf, "%d\n", ls->ls_first);
  268. }
  269. static ssize_t lkfirst_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
  270. {
  271. unsigned first;
  272. int rv;
  273. rv = sscanf(buf, "%u", &first);
  274. if (rv != 1 || first > 1)
  275. return -EINVAL;
  276. spin_lock(&sdp->sd_jindex_spin);
  277. rv = -EBUSY;
  278. if (test_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0)
  279. goto out;
  280. rv = -EINVAL;
  281. if (sdp->sd_args.ar_spectator)
  282. goto out;
  283. if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
  284. goto out;
  285. sdp->sd_lockstruct.ls_first = first;
  286. rv = 0;
  287. out:
  288. spin_unlock(&sdp->sd_jindex_spin);
  289. return rv ? rv : len;
  290. }
  291. static ssize_t first_done_show(struct gfs2_sbd *sdp, char *buf)
  292. {
  293. struct lm_lockstruct *ls = &sdp->sd_lockstruct;
  294. return sprintf(buf, "%d\n", ls->ls_first_done);
  295. }
  296. static ssize_t recover_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
  297. {
  298. unsigned jid;
  299. struct gfs2_jdesc *jd;
  300. int rv;
  301. rv = sscanf(buf, "%u", &jid);
  302. if (rv != 1)
  303. return -EINVAL;
  304. rv = -ESHUTDOWN;
  305. spin_lock(&sdp->sd_jindex_spin);
  306. if (test_bit(SDF_NORECOVERY, &sdp->sd_flags))
  307. goto out;
  308. rv = -EBUSY;
  309. if (sdp->sd_jdesc->jd_jid == jid)
  310. goto out;
  311. rv = -ENOENT;
  312. list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
  313. if (jd->jd_jid != jid)
  314. continue;
  315. rv = slow_work_enqueue(&jd->jd_work);
  316. break;
  317. }
  318. out:
  319. spin_unlock(&sdp->sd_jindex_spin);
  320. return rv ? rv : len;
  321. }
  322. static ssize_t recover_done_show(struct gfs2_sbd *sdp, char *buf)
  323. {
  324. struct lm_lockstruct *ls = &sdp->sd_lockstruct;
  325. return sprintf(buf, "%d\n", ls->ls_recover_jid_done);
  326. }
  327. static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf)
  328. {
  329. struct lm_lockstruct *ls = &sdp->sd_lockstruct;
  330. return sprintf(buf, "%d\n", ls->ls_recover_jid_status);
  331. }
  332. static ssize_t jid_show(struct gfs2_sbd *sdp, char *buf)
  333. {
  334. return sprintf(buf, "%u\n", sdp->sd_lockstruct.ls_jid);
  335. }
  336. static ssize_t jid_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
  337. {
  338. unsigned jid;
  339. int rv;
  340. rv = sscanf(buf, "%u", &jid);
  341. if (rv != 1)
  342. return -EINVAL;
  343. spin_lock(&sdp->sd_jindex_spin);
  344. rv = -EINVAL;
  345. if (sdp->sd_args.ar_spectator)
  346. goto out;
  347. if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
  348. goto out;
  349. rv = -EBUSY;
  350. if (test_and_clear_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0)
  351. goto out;
  352. sdp->sd_lockstruct.ls_jid = jid;
  353. smp_mb__after_clear_bit();
  354. wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID);
  355. rv = 0;
  356. out:
  357. spin_unlock(&sdp->sd_jindex_spin);
  358. return rv ? rv : len;
  359. }
  360. #define GDLM_ATTR(_name,_mode,_show,_store) \
  361. static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
  362. GDLM_ATTR(proto_name, 0444, proto_name_show, NULL);
  363. GDLM_ATTR(block, 0644, block_show, block_store);
  364. GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store);
  365. GDLM_ATTR(jid, 0644, jid_show, jid_store);
  366. GDLM_ATTR(first, 0644, lkfirst_show, lkfirst_store);
  367. GDLM_ATTR(first_done, 0444, first_done_show, NULL);
  368. GDLM_ATTR(recover, 0600, NULL, recover_store);
  369. GDLM_ATTR(recover_done, 0444, recover_done_show, NULL);
  370. GDLM_ATTR(recover_status, 0444, recover_status_show, NULL);
  371. static struct attribute *lock_module_attrs[] = {
  372. &gdlm_attr_proto_name.attr,
  373. &gdlm_attr_block.attr,
  374. &gdlm_attr_withdraw.attr,
  375. &gdlm_attr_jid.attr,
  376. &gdlm_attr_first.attr,
  377. &gdlm_attr_first_done.attr,
  378. &gdlm_attr_recover.attr,
  379. &gdlm_attr_recover_done.attr,
  380. &gdlm_attr_recover_status.attr,
  381. NULL,
  382. };
  383. /*
  384. * get and set struct gfs2_tune fields
  385. */
  386. static ssize_t quota_scale_show(struct gfs2_sbd *sdp, char *buf)
  387. {
  388. return snprintf(buf, PAGE_SIZE, "%u %u\n",
  389. sdp->sd_tune.gt_quota_scale_num,
  390. sdp->sd_tune.gt_quota_scale_den);
  391. }
  392. static ssize_t quota_scale_store(struct gfs2_sbd *sdp, const char *buf,
  393. size_t len)
  394. {
  395. struct gfs2_tune *gt = &sdp->sd_tune;
  396. unsigned int x, y;
  397. if (!capable(CAP_SYS_ADMIN))
  398. return -EACCES;
  399. if (sscanf(buf, "%u %u", &x, &y) != 2 || !y)
  400. return -EINVAL;
  401. spin_lock(&gt->gt_spin);
  402. gt->gt_quota_scale_num = x;
  403. gt->gt_quota_scale_den = y;
  404. spin_unlock(&gt->gt_spin);
  405. return len;
  406. }
  407. static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,
  408. int check_zero, const char *buf, size_t len)
  409. {
  410. struct gfs2_tune *gt = &sdp->sd_tune;
  411. unsigned int x;
  412. if (!capable(CAP_SYS_ADMIN))
  413. return -EACCES;
  414. x = simple_strtoul(buf, NULL, 0);
  415. if (check_zero && !x)
  416. return -EINVAL;
  417. spin_lock(&gt->gt_spin);
  418. *field = x;
  419. spin_unlock(&gt->gt_spin);
  420. return len;
  421. }
  422. #define TUNE_ATTR_3(name, show, store) \
  423. static struct gfs2_attr tune_attr_##name = __ATTR(name, 0644, show, store)
  424. #define TUNE_ATTR_2(name, store) \
  425. static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
  426. { \
  427. return snprintf(buf, PAGE_SIZE, "%u\n", sdp->sd_tune.gt_##name); \
  428. } \
  429. TUNE_ATTR_3(name, name##_show, store)
  430. #define TUNE_ATTR(name, check_zero) \
  431. static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\
  432. { \
  433. return tune_set(sdp, &sdp->sd_tune.gt_##name, check_zero, buf, len); \
  434. } \
  435. TUNE_ATTR_2(name, name##_store)
  436. TUNE_ATTR(quota_warn_period, 0);
  437. TUNE_ATTR(quota_quantum, 0);
  438. TUNE_ATTR(max_readahead, 0);
  439. TUNE_ATTR(complain_secs, 0);
  440. TUNE_ATTR(statfs_slow, 0);
  441. TUNE_ATTR(new_files_jdata, 0);
  442. TUNE_ATTR(quota_simul_sync, 1);
  443. TUNE_ATTR(statfs_quantum, 1);
  444. TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store);
  445. static struct attribute *tune_attrs[] = {
  446. &tune_attr_quota_warn_period.attr,
  447. &tune_attr_quota_quantum.attr,
  448. &tune_attr_max_readahead.attr,
  449. &tune_attr_complain_secs.attr,
  450. &tune_attr_statfs_slow.attr,
  451. &tune_attr_quota_simul_sync.attr,
  452. &tune_attr_statfs_quantum.attr,
  453. &tune_attr_quota_scale.attr,
  454. &tune_attr_new_files_jdata.attr,
  455. NULL,
  456. };
  457. static struct attribute_group tune_group = {
  458. .name = "tune",
  459. .attrs = tune_attrs,
  460. };
  461. static struct attribute_group lock_module_group = {
  462. .name = "lock_module",
  463. .attrs = lock_module_attrs,
  464. };
  465. int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
  466. {
  467. struct super_block *sb = sdp->sd_vfs;
  468. int error;
  469. char ro[20];
  470. char spectator[20];
  471. char *envp[] = { ro, spectator, NULL };
  472. sprintf(ro, "RDONLY=%d", (sb->s_flags & MS_RDONLY) ? 1 : 0);
  473. sprintf(spectator, "SPECTATOR=%d", sdp->sd_args.ar_spectator ? 1 : 0);
  474. sdp->sd_kobj.kset = gfs2_kset;
  475. error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL,
  476. "%s", sdp->sd_table_name);
  477. if (error)
  478. goto fail;
  479. error = sysfs_create_group(&sdp->sd_kobj, &tune_group);
  480. if (error)
  481. goto fail_reg;
  482. error = sysfs_create_group(&sdp->sd_kobj, &lock_module_group);
  483. if (error)
  484. goto fail_tune;
  485. error = sysfs_create_link(&sdp->sd_kobj,
  486. &disk_to_dev(sb->s_bdev->bd_disk)->kobj,
  487. "device");
  488. if (error)
  489. goto fail_lock_module;
  490. kobject_uevent_env(&sdp->sd_kobj, KOBJ_ADD, envp);
  491. return 0;
  492. fail_lock_module:
  493. sysfs_remove_group(&sdp->sd_kobj, &lock_module_group);
  494. fail_tune:
  495. sysfs_remove_group(&sdp->sd_kobj, &tune_group);
  496. fail_reg:
  497. kobject_put(&sdp->sd_kobj);
  498. fail:
  499. fs_err(sdp, "error %d adding sysfs files", error);
  500. return error;
  501. }
  502. void gfs2_sys_fs_del(struct gfs2_sbd *sdp)
  503. {
  504. sysfs_remove_link(&sdp->sd_kobj, "device");
  505. sysfs_remove_group(&sdp->sd_kobj, &tune_group);
  506. sysfs_remove_group(&sdp->sd_kobj, &lock_module_group);
  507. kobject_put(&sdp->sd_kobj);
  508. }
  509. static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
  510. struct kobj_uevent_env *env)
  511. {
  512. struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
  513. const u8 *uuid = sdp->sd_sb.sb_uuid;
  514. add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name);
  515. add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
  516. if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags))
  517. add_uevent_var(env, "JOURNALID=%u", sdp->sd_lockstruct.ls_jid);
  518. if (gfs2_uuid_valid(uuid))
  519. add_uevent_var(env, "UUID=%pUB", uuid);
  520. return 0;
  521. }
  522. static const struct kset_uevent_ops gfs2_uevent_ops = {
  523. .uevent = gfs2_uevent,
  524. };
  525. int gfs2_sys_init(void)
  526. {
  527. gfs2_kset = kset_create_and_add("gfs2", &gfs2_uevent_ops, fs_kobj);
  528. if (!gfs2_kset)
  529. return -ENOMEM;
  530. return 0;
  531. }
  532. void gfs2_sys_uninit(void)
  533. {
  534. kset_unregister(gfs2_kset);
  535. }