.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
---|
2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * load/unload driver, mount/dismount volumes |
---|
7 | 8 | * |
---|
8 | 9 | * Copyright (C) 2002, 2004 Oracle. All rights reserved. |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or |
---|
11 | | - * modify it under the terms of the GNU General Public |
---|
12 | | - * License as published by the Free Software Foundation; either |
---|
13 | | - * version 2 of the License, or (at your option) any later version. |
---|
14 | | - * |
---|
15 | | - * This program is distributed in the hope that it will be useful, |
---|
16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | | - * General Public License for more details. |
---|
19 | | - * |
---|
20 | | - * You should have received a copy of the GNU General Public |
---|
21 | | - * License along with this program; if not, write to the |
---|
22 | | - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
23 | | - * Boston, MA 021110-1307, USA. |
---|
24 | 10 | */ |
---|
25 | 11 | |
---|
26 | 12 | #include <linux/module.h> |
---|
.. | .. |
---|
85 | 71 | |
---|
86 | 72 | MODULE_AUTHOR("Oracle"); |
---|
87 | 73 | MODULE_LICENSE("GPL"); |
---|
| 74 | +MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY); |
---|
88 | 75 | MODULE_DESCRIPTION("OCFS2 cluster file system"); |
---|
89 | 76 | |
---|
90 | 77 | struct mount_options |
---|
.. | .. |
---|
134 | 121 | int block, |
---|
135 | 122 | int sect_size); |
---|
136 | 123 | static struct inode *ocfs2_alloc_inode(struct super_block *sb); |
---|
137 | | -static void ocfs2_destroy_inode(struct inode *inode); |
---|
| 124 | +static void ocfs2_free_inode(struct inode *inode); |
---|
138 | 125 | static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend); |
---|
139 | 126 | static int ocfs2_enable_quotas(struct ocfs2_super *osb); |
---|
140 | 127 | static void ocfs2_disable_quotas(struct ocfs2_super *osb); |
---|
.. | .. |
---|
147 | 134 | static const struct super_operations ocfs2_sops = { |
---|
148 | 135 | .statfs = ocfs2_statfs, |
---|
149 | 136 | .alloc_inode = ocfs2_alloc_inode, |
---|
150 | | - .destroy_inode = ocfs2_destroy_inode, |
---|
| 137 | + .free_inode = ocfs2_free_inode, |
---|
151 | 138 | .drop_inode = ocfs2_drop_inode, |
---|
152 | 139 | .evict_inode = ocfs2_evict_inode, |
---|
153 | 140 | .sync_fs = ocfs2_sync_fs, |
---|
.. | .. |
---|
234 | 221 | int i, out = 0; |
---|
235 | 222 | unsigned long flags; |
---|
236 | 223 | |
---|
237 | | - out += snprintf(buf + out, len - out, |
---|
| 224 | + out += scnprintf(buf + out, len - out, |
---|
238 | 225 | "%10s => Id: %-s Uuid: %-s Gen: 0x%X Label: %-s\n", |
---|
239 | 226 | "Device", osb->dev_str, osb->uuid_str, |
---|
240 | 227 | osb->fs_generation, osb->vol_label); |
---|
241 | 228 | |
---|
242 | | - out += snprintf(buf + out, len - out, |
---|
| 229 | + out += scnprintf(buf + out, len - out, |
---|
243 | 230 | "%10s => State: %d Flags: 0x%lX\n", "Volume", |
---|
244 | 231 | atomic_read(&osb->vol_state), osb->osb_flags); |
---|
245 | 232 | |
---|
246 | | - out += snprintf(buf + out, len - out, |
---|
| 233 | + out += scnprintf(buf + out, len - out, |
---|
247 | 234 | "%10s => Block: %lu Cluster: %d\n", "Sizes", |
---|
248 | 235 | osb->sb->s_blocksize, osb->s_clustersize); |
---|
249 | 236 | |
---|
250 | | - out += snprintf(buf + out, len - out, |
---|
| 237 | + out += scnprintf(buf + out, len - out, |
---|
251 | 238 | "%10s => Compat: 0x%X Incompat: 0x%X " |
---|
252 | 239 | "ROcompat: 0x%X\n", |
---|
253 | 240 | "Features", osb->s_feature_compat, |
---|
254 | 241 | osb->s_feature_incompat, osb->s_feature_ro_compat); |
---|
255 | 242 | |
---|
256 | | - out += snprintf(buf + out, len - out, |
---|
| 243 | + out += scnprintf(buf + out, len - out, |
---|
257 | 244 | "%10s => Opts: 0x%lX AtimeQuanta: %u\n", "Mount", |
---|
258 | 245 | osb->s_mount_opt, osb->s_atime_quantum); |
---|
259 | 246 | |
---|
260 | 247 | if (cconn) { |
---|
261 | | - out += snprintf(buf + out, len - out, |
---|
| 248 | + out += scnprintf(buf + out, len - out, |
---|
262 | 249 | "%10s => Stack: %s Name: %*s " |
---|
263 | 250 | "Version: %d.%d\n", "Cluster", |
---|
264 | 251 | (*osb->osb_cluster_stack == '\0' ? |
---|
.. | .. |
---|
269 | 256 | } |
---|
270 | 257 | |
---|
271 | 258 | spin_lock_irqsave(&osb->dc_task_lock, flags); |
---|
272 | | - out += snprintf(buf + out, len - out, |
---|
| 259 | + out += scnprintf(buf + out, len - out, |
---|
273 | 260 | "%10s => Pid: %d Count: %lu WakeSeq: %lu " |
---|
274 | 261 | "WorkSeq: %lu\n", "DownCnvt", |
---|
275 | 262 | (osb->dc_task ? task_pid_nr(osb->dc_task) : -1), |
---|
.. | .. |
---|
278 | 265 | spin_unlock_irqrestore(&osb->dc_task_lock, flags); |
---|
279 | 266 | |
---|
280 | 267 | spin_lock(&osb->osb_lock); |
---|
281 | | - out += snprintf(buf + out, len - out, "%10s => Pid: %d Nodes:", |
---|
| 268 | + out += scnprintf(buf + out, len - out, "%10s => Pid: %d Nodes:", |
---|
282 | 269 | "Recovery", |
---|
283 | 270 | (osb->recovery_thread_task ? |
---|
284 | 271 | task_pid_nr(osb->recovery_thread_task) : -1)); |
---|
285 | 272 | if (rm->rm_used == 0) |
---|
286 | | - out += snprintf(buf + out, len - out, " None\n"); |
---|
| 273 | + out += scnprintf(buf + out, len - out, " None\n"); |
---|
287 | 274 | else { |
---|
288 | 275 | for (i = 0; i < rm->rm_used; i++) |
---|
289 | | - out += snprintf(buf + out, len - out, " %d", |
---|
| 276 | + out += scnprintf(buf + out, len - out, " %d", |
---|
290 | 277 | rm->rm_entries[i]); |
---|
291 | | - out += snprintf(buf + out, len - out, "\n"); |
---|
| 278 | + out += scnprintf(buf + out, len - out, "\n"); |
---|
292 | 279 | } |
---|
293 | 280 | spin_unlock(&osb->osb_lock); |
---|
294 | 281 | |
---|
295 | | - out += snprintf(buf + out, len - out, |
---|
| 282 | + out += scnprintf(buf + out, len - out, |
---|
296 | 283 | "%10s => Pid: %d Interval: %lu\n", "Commit", |
---|
297 | 284 | (osb->commit_task ? task_pid_nr(osb->commit_task) : -1), |
---|
298 | 285 | osb->osb_commit_interval); |
---|
299 | 286 | |
---|
300 | | - out += snprintf(buf + out, len - out, |
---|
| 287 | + out += scnprintf(buf + out, len - out, |
---|
301 | 288 | "%10s => State: %d TxnId: %lu NumTxns: %d\n", |
---|
302 | 289 | "Journal", osb->journal->j_state, |
---|
303 | 290 | osb->journal->j_trans_id, |
---|
304 | 291 | atomic_read(&osb->journal->j_num_trans)); |
---|
305 | 292 | |
---|
306 | | - out += snprintf(buf + out, len - out, |
---|
| 293 | + out += scnprintf(buf + out, len - out, |
---|
307 | 294 | "%10s => GlobalAllocs: %d LocalAllocs: %d " |
---|
308 | 295 | "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n", |
---|
309 | 296 | "Stats", |
---|
.. | .. |
---|
313 | 300 | atomic_read(&osb->alloc_stats.moves), |
---|
314 | 301 | atomic_read(&osb->alloc_stats.bg_extends)); |
---|
315 | 302 | |
---|
316 | | - out += snprintf(buf + out, len - out, |
---|
| 303 | + out += scnprintf(buf + out, len - out, |
---|
317 | 304 | "%10s => State: %u Descriptor: %llu Size: %u bits " |
---|
318 | 305 | "Default: %u bits\n", |
---|
319 | 306 | "LocalAlloc", osb->local_alloc_state, |
---|
.. | .. |
---|
321 | 308 | osb->local_alloc_bits, osb->local_alloc_default_bits); |
---|
322 | 309 | |
---|
323 | 310 | spin_lock(&osb->osb_lock); |
---|
324 | | - out += snprintf(buf + out, len - out, |
---|
| 311 | + out += scnprintf(buf + out, len - out, |
---|
325 | 312 | "%10s => InodeSlot: %d StolenInodes: %d, " |
---|
326 | 313 | "MetaSlot: %d StolenMeta: %d\n", "Steal", |
---|
327 | 314 | osb->s_inode_steal_slot, |
---|
.. | .. |
---|
330 | 317 | atomic_read(&osb->s_num_meta_stolen)); |
---|
331 | 318 | spin_unlock(&osb->osb_lock); |
---|
332 | 319 | |
---|
333 | | - out += snprintf(buf + out, len - out, "OrphanScan => "); |
---|
334 | | - out += snprintf(buf + out, len - out, "Local: %u Global: %u ", |
---|
| 320 | + out += scnprintf(buf + out, len - out, "OrphanScan => "); |
---|
| 321 | + out += scnprintf(buf + out, len - out, "Local: %u Global: %u ", |
---|
335 | 322 | os->os_count, os->os_seqno); |
---|
336 | | - out += snprintf(buf + out, len - out, " Last Scan: "); |
---|
| 323 | + out += scnprintf(buf + out, len - out, " Last Scan: "); |
---|
337 | 324 | if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE) |
---|
338 | | - out += snprintf(buf + out, len - out, "Disabled\n"); |
---|
| 325 | + out += scnprintf(buf + out, len - out, "Disabled\n"); |
---|
339 | 326 | else |
---|
340 | | - out += snprintf(buf + out, len - out, "%lu seconds ago\n", |
---|
| 327 | + out += scnprintf(buf + out, len - out, "%lu seconds ago\n", |
---|
341 | 328 | (unsigned long)(ktime_get_seconds() - os->os_scantime)); |
---|
342 | 329 | |
---|
343 | | - out += snprintf(buf + out, len - out, "%10s => %3s %10s\n", |
---|
| 330 | + out += scnprintf(buf + out, len - out, "%10s => %3s %10s\n", |
---|
344 | 331 | "Slots", "Num", "RecoGen"); |
---|
345 | 332 | for (i = 0; i < osb->max_slots; ++i) { |
---|
346 | | - out += snprintf(buf + out, len - out, |
---|
| 333 | + out += scnprintf(buf + out, len - out, |
---|
347 | 334 | "%10s %c %3d %10d\n", |
---|
348 | 335 | " ", |
---|
349 | 336 | (i == osb->slot_num ? '*' : ' '), |
---|
.. | .. |
---|
575 | 562 | return &oi->vfs_inode; |
---|
576 | 563 | } |
---|
577 | 564 | |
---|
578 | | -static void ocfs2_i_callback(struct rcu_head *head) |
---|
| 565 | +static void ocfs2_free_inode(struct inode *inode) |
---|
579 | 566 | { |
---|
580 | | - struct inode *inode = container_of(head, struct inode, i_rcu); |
---|
581 | 567 | kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode)); |
---|
582 | | -} |
---|
583 | | - |
---|
584 | | -static void ocfs2_destroy_inode(struct inode *inode) |
---|
585 | | -{ |
---|
586 | | - call_rcu(&inode->i_rcu, ocfs2_i_callback); |
---|
587 | 568 | } |
---|
588 | 569 | |
---|
589 | 570 | static unsigned long long ocfs2_max_file_offset(unsigned int bbits, |
---|
.. | .. |
---|
600 | 581 | */ |
---|
601 | 582 | |
---|
602 | 583 | #if BITS_PER_LONG == 32 |
---|
603 | | -# if defined(CONFIG_LBDAF) |
---|
604 | 584 | BUILD_BUG_ON(sizeof(sector_t) != 8); |
---|
605 | 585 | /* |
---|
606 | 586 | * We might be limited by page cache size. |
---|
.. | .. |
---|
614 | 594 | */ |
---|
615 | 595 | bitshift = 31; |
---|
616 | 596 | } |
---|
617 | | -# else |
---|
618 | | - /* |
---|
619 | | - * We are limited by the size of sector_t. Use block size, as |
---|
620 | | - * that's what we expose to the VFS. |
---|
621 | | - */ |
---|
622 | | - bytes = 1 << bbits; |
---|
623 | | - trim = 1; |
---|
624 | | - bitshift = 31; |
---|
625 | | -# endif |
---|
626 | 597 | #endif |
---|
627 | 598 | |
---|
628 | 599 | /* |
---|
.. | .. |
---|
956 | 927 | status = -ENOENT; |
---|
957 | 928 | goto out_quota_off; |
---|
958 | 929 | } |
---|
959 | | - status = dquot_enable(inode[type], type, QFMT_OCFS2, |
---|
960 | | - DQUOT_USAGE_ENABLED); |
---|
| 930 | + status = dquot_load_quota_inode(inode[type], type, QFMT_OCFS2, |
---|
| 931 | + DQUOT_USAGE_ENABLED); |
---|
961 | 932 | if (status < 0) |
---|
962 | 933 | goto out_quota_off; |
---|
963 | 934 | } |
---|
.. | .. |
---|
1109 | 1080 | |
---|
1110 | 1081 | osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, |
---|
1111 | 1082 | ocfs2_debugfs_root); |
---|
1112 | | - if (!osb->osb_debug_root) { |
---|
1113 | | - status = -EINVAL; |
---|
1114 | | - mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n"); |
---|
1115 | | - goto read_super_error; |
---|
1116 | | - } |
---|
1117 | 1083 | |
---|
1118 | | - osb->osb_ctxt = debugfs_create_file("fs_state", S_IFREG|S_IRUSR, |
---|
1119 | | - osb->osb_debug_root, |
---|
1120 | | - osb, |
---|
1121 | | - &ocfs2_osb_debug_fops); |
---|
1122 | | - if (!osb->osb_ctxt) { |
---|
1123 | | - status = -EINVAL; |
---|
1124 | | - mlog_errno(status); |
---|
1125 | | - goto read_super_error; |
---|
1126 | | - } |
---|
| 1084 | + debugfs_create_file("fs_state", S_IFREG|S_IRUSR, osb->osb_debug_root, |
---|
| 1085 | + osb, &ocfs2_osb_debug_fops); |
---|
1127 | 1086 | |
---|
1128 | | - if (ocfs2_meta_ecc(osb)) { |
---|
1129 | | - status = ocfs2_blockcheck_stats_debugfs_install( |
---|
1130 | | - &osb->osb_ecc_stats, |
---|
1131 | | - osb->osb_debug_root); |
---|
1132 | | - if (status) { |
---|
1133 | | - mlog(ML_ERROR, |
---|
1134 | | - "Unable to create blockcheck statistics " |
---|
1135 | | - "files\n"); |
---|
1136 | | - goto read_super_error; |
---|
1137 | | - } |
---|
1138 | | - } |
---|
| 1087 | + if (ocfs2_meta_ecc(osb)) |
---|
| 1088 | + ocfs2_blockcheck_stats_debugfs_install( &osb->osb_ecc_stats, |
---|
| 1089 | + osb->osb_debug_root); |
---|
1139 | 1090 | |
---|
1140 | 1091 | status = ocfs2_mount_volume(sb); |
---|
1141 | 1092 | if (status < 0) |
---|
.. | .. |
---|
1149 | 1100 | mlog_errno(status); |
---|
1150 | 1101 | goto read_super_error; |
---|
1151 | 1102 | } |
---|
1152 | | - |
---|
1153 | | - root = d_make_root(inode); |
---|
1154 | | - if (!root) { |
---|
1155 | | - status = -ENOMEM; |
---|
1156 | | - mlog_errno(status); |
---|
1157 | | - goto read_super_error; |
---|
1158 | | - } |
---|
1159 | | - |
---|
1160 | | - sb->s_root = root; |
---|
1161 | | - |
---|
1162 | | - ocfs2_complete_mount_recovery(osb); |
---|
1163 | 1103 | |
---|
1164 | 1104 | osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL, |
---|
1165 | 1105 | &ocfs2_kset->kobj); |
---|
.. | .. |
---|
1177 | 1117 | "/sys/fs/ocfs2/%s/filecheck.\n", sb->s_id); |
---|
1178 | 1118 | goto read_super_error; |
---|
1179 | 1119 | } |
---|
| 1120 | + |
---|
| 1121 | + root = d_make_root(inode); |
---|
| 1122 | + if (!root) { |
---|
| 1123 | + status = -ENOMEM; |
---|
| 1124 | + mlog_errno(status); |
---|
| 1125 | + goto read_super_error; |
---|
| 1126 | + } |
---|
| 1127 | + |
---|
| 1128 | + sb->s_root = root; |
---|
| 1129 | + |
---|
| 1130 | + ocfs2_complete_mount_recovery(osb); |
---|
1180 | 1131 | |
---|
1181 | 1132 | if (ocfs2_mount_local(osb)) |
---|
1182 | 1133 | snprintf(nodestr, sizeof(nodestr), "local"); |
---|
.. | .. |
---|
1622 | 1573 | goto out2; |
---|
1623 | 1574 | |
---|
1624 | 1575 | ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL); |
---|
1625 | | - if (!ocfs2_debugfs_root) { |
---|
1626 | | - status = -ENOMEM; |
---|
1627 | | - mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n"); |
---|
1628 | | - goto out3; |
---|
1629 | | - } |
---|
1630 | 1576 | |
---|
1631 | 1577 | ocfs2_set_locking_protocol(); |
---|
1632 | 1578 | |
---|
.. | .. |
---|
1848 | 1794 | if (ocfs2_is_hard_readonly(osb)) |
---|
1849 | 1795 | goto leave; |
---|
1850 | 1796 | |
---|
| 1797 | + mutex_init(&osb->obs_trim_fs_mutex); |
---|
| 1798 | + |
---|
1851 | 1799 | status = ocfs2_dlm_init(osb); |
---|
1852 | 1800 | if (status < 0) { |
---|
1853 | 1801 | mlog_errno(status); |
---|
.. | .. |
---|
1913 | 1861 | |
---|
1914 | 1862 | kset_unregister(osb->osb_dev_kset); |
---|
1915 | 1863 | |
---|
1916 | | - debugfs_remove(osb->osb_ctxt); |
---|
1917 | | - |
---|
1918 | 1864 | /* Orphan scan should be stopped as early as possible */ |
---|
1919 | 1865 | ocfs2_orphan_scan_stop(osb); |
---|
1920 | 1866 | |
---|
.. | .. |
---|
1970 | 1916 | ocfs2_dlm_shutdown(osb, hangup_needed); |
---|
1971 | 1917 | |
---|
1972 | 1918 | ocfs2_blockcheck_stats_debugfs_remove(&osb->osb_ecc_stats); |
---|
1973 | | - debugfs_remove(osb->osb_debug_root); |
---|
| 1919 | + debugfs_remove_recursive(osb->osb_debug_root); |
---|
1974 | 1920 | |
---|
1975 | 1921 | if (hangup_needed) |
---|
1976 | 1922 | ocfs2_cluster_hangup(osb->uuid_str, strlen(osb->uuid_str)); |
---|