.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
---|
3 | 4 | * 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 | 5 | */ |
---|
9 | 6 | |
---|
10 | 7 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
121 | 118 | |
---|
122 | 119 | static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf) |
---|
123 | 120 | { |
---|
124 | | - unsigned int b = test_bit(SDF_SHUTDOWN, &sdp->sd_flags); |
---|
| 121 | + unsigned int b = gfs2_withdrawn(sdp); |
---|
125 | 122 | return snprintf(buf, PAGE_SIZE, "%u\n", b); |
---|
126 | 123 | } |
---|
127 | 124 | |
---|
.. | .. |
---|
139 | 136 | if (val != 1) |
---|
140 | 137 | return -EINVAL; |
---|
141 | 138 | |
---|
142 | | - gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n"); |
---|
| 139 | + gfs2_lm(sdp, "withdrawing from cluster at user's request\n"); |
---|
| 140 | + gfs2_withdraw(sdp); |
---|
143 | 141 | |
---|
144 | 142 | return len; |
---|
145 | 143 | } |
---|
.. | .. |
---|
299 | 297 | &gfs2_attr_demote_rq.attr, |
---|
300 | 298 | NULL, |
---|
301 | 299 | }; |
---|
| 300 | +ATTRIBUTE_GROUPS(gfs2); |
---|
302 | 301 | |
---|
303 | 302 | static void gfs2_sbd_release(struct kobject *kobj) |
---|
304 | 303 | { |
---|
305 | 304 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); |
---|
306 | 305 | |
---|
307 | | - kfree(sdp); |
---|
| 306 | + complete(&sdp->sd_kobj_unregister); |
---|
308 | 307 | } |
---|
309 | 308 | |
---|
310 | 309 | static struct kobj_type gfs2_ktype = { |
---|
311 | 310 | .release = gfs2_sbd_release, |
---|
312 | | - .default_attrs = gfs2_attrs, |
---|
| 311 | + .default_groups = gfs2_groups, |
---|
313 | 312 | .sysfs_ops = &gfs2_attr_ops, |
---|
314 | 313 | }; |
---|
315 | 314 | |
---|
.. | .. |
---|
436 | 435 | * never clear the DFL_BLOCK_LOCKS flag, so all our locks would |
---|
437 | 436 | * permanently stop working. |
---|
438 | 437 | */ |
---|
| 438 | + if (!sdp->sd_jdesc) |
---|
| 439 | + goto out; |
---|
439 | 440 | if (sdp->sd_jdesc->jd_jid == jid && !sdp->sd_args.ar_spectator) |
---|
440 | 441 | goto out; |
---|
441 | 442 | rv = -ENOENT; |
---|
.. | .. |
---|
650 | 651 | char ro[20]; |
---|
651 | 652 | char spectator[20]; |
---|
652 | 653 | char *envp[] = { ro, spectator, NULL }; |
---|
653 | | - int sysfs_frees_sdp = 0; |
---|
654 | 654 | |
---|
655 | 655 | sprintf(ro, "RDONLY=%d", sb_rdonly(sb)); |
---|
656 | 656 | sprintf(spectator, "SPECTATOR=%d", sdp->sd_args.ar_spectator ? 1 : 0); |
---|
657 | 657 | |
---|
| 658 | + init_completion(&sdp->sd_kobj_unregister); |
---|
658 | 659 | sdp->sd_kobj.kset = gfs2_kset; |
---|
659 | 660 | error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL, |
---|
660 | 661 | "%s", sdp->sd_table_name); |
---|
661 | 662 | if (error) |
---|
662 | 663 | goto fail_reg; |
---|
663 | 664 | |
---|
664 | | - sysfs_frees_sdp = 1; /* Freeing sdp is now done by sysfs calling |
---|
665 | | - function gfs2_sbd_release. */ |
---|
666 | 665 | error = sysfs_create_group(&sdp->sd_kobj, &tune_group); |
---|
667 | 666 | if (error) |
---|
668 | 667 | goto fail_reg; |
---|
.. | .. |
---|
685 | 684 | fail_tune: |
---|
686 | 685 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); |
---|
687 | 686 | fail_reg: |
---|
688 | | - free_percpu(sdp->sd_lkstats); |
---|
689 | 687 | fs_err(sdp, "error %d adding sysfs files\n", error); |
---|
690 | | - if (sysfs_frees_sdp) |
---|
691 | | - kobject_put(&sdp->sd_kobj); |
---|
692 | | - else |
---|
693 | | - kfree(sdp); |
---|
| 688 | + kobject_put(&sdp->sd_kobj); |
---|
| 689 | + wait_for_completion(&sdp->sd_kobj_unregister); |
---|
694 | 690 | sb->s_fs_info = NULL; |
---|
695 | 691 | return error; |
---|
696 | 692 | } |
---|
.. | .. |
---|
701 | 697 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); |
---|
702 | 698 | sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); |
---|
703 | 699 | kobject_put(&sdp->sd_kobj); |
---|
| 700 | + wait_for_completion(&sdp->sd_kobj_unregister); |
---|
704 | 701 | } |
---|
705 | 702 | |
---|
706 | 703 | static int gfs2_uevent(struct kset *kset, struct kobject *kobj, |
---|