resize.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /* -*- mode: c; c-basic-offset: 8; -*-
  2. * vim: noexpandtab sw=8 ts=8 sts=0:
  3. *
  4. * resize.c
  5. *
  6. * volume resize.
  7. * Inspired by ext3/resize.c.
  8. *
  9. * Copyright (C) 2007 Oracle. All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public
  13. * License as published by the Free Software Foundation; either
  14. * version 2 of the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public
  22. * License along with this program; if not, write to the
  23. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24. * Boston, MA 021110-1307, USA.
  25. */
  26. #include <linux/fs.h>
  27. #include <linux/types.h>
  28. #include <cluster/masklog.h>
  29. #include "ocfs2.h"
  30. #include "alloc.h"
  31. #include "dlmglue.h"
  32. #include "inode.h"
  33. #include "journal.h"
  34. #include "super.h"
  35. #include "sysfile.h"
  36. #include "uptodate.h"
  37. #include "ocfs2_trace.h"
  38. #include "buffer_head_io.h"
  39. #include "suballoc.h"
  40. #include "resize.h"
  41. /*
  42. * Check whether there are new backup superblocks exist
  43. * in the last group. If there are some, mark them or clear
  44. * them in the bitmap.
  45. *
  46. * Return how many backups we find in the last group.
  47. */
  48. static u16 ocfs2_calc_new_backup_super(struct inode *inode,
  49. struct ocfs2_group_desc *gd,
  50. u16 cl_cpg,
  51. int set)
  52. {
  53. int i;
  54. u16 backups = 0;
  55. u32 cluster;
  56. u64 blkno, gd_blkno, lgd_blkno = le64_to_cpu(gd->bg_blkno);
  57. for (i = 0; i < OCFS2_MAX_BACKUP_SUPERBLOCKS; i++) {
  58. blkno = ocfs2_backup_super_blkno(inode->i_sb, i);
  59. cluster = ocfs2_blocks_to_clusters(inode->i_sb, blkno);
  60. gd_blkno = ocfs2_which_cluster_group(inode, cluster);
  61. if (gd_blkno < lgd_blkno)
  62. continue;
  63. else if (gd_blkno > lgd_blkno)
  64. break;
  65. if (set)
  66. ocfs2_set_bit(cluster % cl_cpg,
  67. (unsigned long *)gd->bg_bitmap);
  68. else
  69. ocfs2_clear_bit(cluster % cl_cpg,
  70. (unsigned long *)gd->bg_bitmap);
  71. backups++;
  72. }
  73. return backups;
  74. }
  75. static int ocfs2_update_last_group_and_inode(handle_t *handle,
  76. struct inode *bm_inode,
  77. struct buffer_head *bm_bh,
  78. struct buffer_head *group_bh,
  79. u32 first_new_cluster,
  80. int new_clusters)
  81. {
  82. int ret = 0;
  83. struct ocfs2_super *osb = OCFS2_SB(bm_inode->i_sb);
  84. struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bm_bh->b_data;
  85. struct ocfs2_chain_list *cl = &fe->id2.i_chain;
  86. struct ocfs2_chain_rec *cr;
  87. struct ocfs2_group_desc *group;
  88. u16 chain, num_bits, backups = 0;
  89. u16 cl_bpc = le16_to_cpu(cl->cl_bpc);
  90. u16 cl_cpg = le16_to_cpu(cl->cl_cpg);
  91. trace_ocfs2_update_last_group_and_inode(new_clusters,
  92. first_new_cluster);
  93. ret = ocfs2_journal_access_gd(handle, INODE_CACHE(bm_inode),
  94. group_bh, OCFS2_JOURNAL_ACCESS_WRITE);
  95. if (ret < 0) {
  96. mlog_errno(ret);
  97. goto out;
  98. }
  99. group = (struct ocfs2_group_desc *)group_bh->b_data;
  100. /* update the group first. */
  101. num_bits = new_clusters * cl_bpc;
  102. le16_add_cpu(&group->bg_bits, num_bits);
  103. le16_add_cpu(&group->bg_free_bits_count, num_bits);
  104. /*
  105. * check whether there are some new backup superblocks exist in
  106. * this group and update the group bitmap accordingly.
  107. */
  108. if (OCFS2_HAS_COMPAT_FEATURE(osb->sb,
  109. OCFS2_FEATURE_COMPAT_BACKUP_SB)) {
  110. backups = ocfs2_calc_new_backup_super(bm_inode,
  111. group,
  112. cl_cpg, 1);
  113. le16_add_cpu(&group->bg_free_bits_count, -1 * backups);
  114. }
  115. ocfs2_journal_dirty(handle, group_bh);
  116. /* update the inode accordingly. */
  117. ret = ocfs2_journal_access_di(handle, INODE_CACHE(bm_inode), bm_bh,
  118. OCFS2_JOURNAL_ACCESS_WRITE);
  119. if (ret < 0) {
  120. mlog_errno(ret);
  121. goto out_rollback;
  122. }
  123. chain = le16_to_cpu(group->bg_chain);
  124. cr = (&cl->cl_recs[chain]);
  125. le32_add_cpu(&cr->c_total, num_bits);
  126. le32_add_cpu(&cr->c_free, num_bits);
  127. le32_add_cpu(&fe->id1.bitmap1.i_total, num_bits);
  128. le32_add_cpu(&fe->i_clusters, new_clusters);
  129. if (backups) {
  130. le32_add_cpu(&cr->c_free, -1 * backups);
  131. le32_add_cpu(&fe->id1.bitmap1.i_used, backups);
  132. }
  133. spin_lock(&OCFS2_I(bm_inode)->ip_lock);
  134. OCFS2_I(bm_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
  135. le64_add_cpu(&fe->i_size, (u64)new_clusters << osb->s_clustersize_bits);
  136. spin_unlock(&OCFS2_I(bm_inode)->ip_lock);
  137. i_size_write(bm_inode, le64_to_cpu(fe->i_size));
  138. ocfs2_journal_dirty(handle, bm_bh);
  139. out_rollback:
  140. if (ret < 0) {
  141. ocfs2_calc_new_backup_super(bm_inode,
  142. group,
  143. cl_cpg, 0);
  144. le16_add_cpu(&group->bg_free_bits_count, backups);
  145. le16_add_cpu(&group->bg_bits, -1 * num_bits);
  146. le16_add_cpu(&group->bg_free_bits_count, -1 * num_bits);
  147. }
  148. out:
  149. if (ret)
  150. mlog_errno(ret);
  151. return ret;
  152. }
  153. static int update_backups(struct inode * inode, u32 clusters, char *data)
  154. {
  155. int i, ret = 0;
  156. u32 cluster;
  157. u64 blkno;
  158. struct buffer_head *backup = NULL;
  159. struct ocfs2_dinode *backup_di = NULL;
  160. struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
  161. /* calculate the real backups we need to update. */
  162. for (i = 0; i < OCFS2_MAX_BACKUP_SUPERBLOCKS; i++) {
  163. blkno = ocfs2_backup_super_blkno(inode->i_sb, i);
  164. cluster = ocfs2_blocks_to_clusters(inode->i_sb, blkno);
  165. if (cluster > clusters)
  166. break;
  167. ret = ocfs2_read_blocks_sync(osb, blkno, 1, &backup);
  168. if (ret < 0) {
  169. mlog_errno(ret);
  170. break;
  171. }
  172. memcpy(backup->b_data, data, inode->i_sb->s_blocksize);
  173. backup_di = (struct ocfs2_dinode *)backup->b_data;
  174. backup_di->i_blkno = cpu_to_le64(blkno);
  175. ret = ocfs2_write_super_or_backup(osb, backup);
  176. brelse(backup);
  177. backup = NULL;
  178. if (ret < 0) {
  179. mlog_errno(ret);
  180. break;
  181. }
  182. }
  183. return ret;
  184. }
  185. static void ocfs2_update_super_and_backups(struct inode *inode,
  186. int new_clusters)
  187. {
  188. int ret;
  189. u32 clusters = 0;
  190. struct buffer_head *super_bh = NULL;
  191. struct ocfs2_dinode *super_di = NULL;
  192. struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
  193. /*
  194. * update the superblock last.
  195. * It doesn't matter if the write failed.
  196. */
  197. ret = ocfs2_read_blocks_sync(osb, OCFS2_SUPER_BLOCK_BLKNO, 1,
  198. &super_bh);
  199. if (ret < 0) {
  200. mlog_errno(ret);
  201. goto out;
  202. }
  203. super_di = (struct ocfs2_dinode *)super_bh->b_data;
  204. le32_add_cpu(&super_di->i_clusters, new_clusters);
  205. clusters = le32_to_cpu(super_di->i_clusters);
  206. ret = ocfs2_write_super_or_backup(osb, super_bh);
  207. if (ret < 0) {
  208. mlog_errno(ret);
  209. goto out;
  210. }
  211. if (OCFS2_HAS_COMPAT_FEATURE(osb->sb, OCFS2_FEATURE_COMPAT_BACKUP_SB))
  212. ret = update_backups(inode, clusters, super_bh->b_data);
  213. out:
  214. brelse(super_bh);
  215. if (ret)
  216. printk(KERN_WARNING "ocfs2: Failed to update super blocks on %s"
  217. " during fs resize. This condition is not fatal,"
  218. " but fsck.ocfs2 should be run to fix it\n",
  219. osb->dev_str);
  220. return;
  221. }
  222. /*
  223. * Extend the filesystem to the new number of clusters specified. This entry
  224. * point is only used to extend the current filesystem to the end of the last
  225. * existing group.
  226. */
  227. int ocfs2_group_extend(struct inode * inode, int new_clusters)
  228. {
  229. int ret;
  230. handle_t *handle;
  231. struct buffer_head *main_bm_bh = NULL;
  232. struct buffer_head *group_bh = NULL;
  233. struct inode *main_bm_inode = NULL;
  234. struct ocfs2_dinode *fe = NULL;
  235. struct ocfs2_group_desc *group = NULL;
  236. struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
  237. u16 cl_bpc;
  238. u32 first_new_cluster;
  239. u64 lgd_blkno;
  240. if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
  241. return -EROFS;
  242. if (new_clusters < 0)
  243. return -EINVAL;
  244. else if (new_clusters == 0)
  245. return 0;
  246. main_bm_inode = ocfs2_get_system_file_inode(osb,
  247. GLOBAL_BITMAP_SYSTEM_INODE,
  248. OCFS2_INVALID_SLOT);
  249. if (!main_bm_inode) {
  250. ret = -EINVAL;
  251. mlog_errno(ret);
  252. goto out;
  253. }
  254. mutex_lock(&main_bm_inode->i_mutex);
  255. ret = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 1);
  256. if (ret < 0) {
  257. mlog_errno(ret);
  258. goto out_mutex;
  259. }
  260. fe = (struct ocfs2_dinode *)main_bm_bh->b_data;
  261. /* main_bm_bh is validated by inode read inside ocfs2_inode_lock(),
  262. * so any corruption is a code bug. */
  263. BUG_ON(!OCFS2_IS_VALID_DINODE(fe));
  264. if (le16_to_cpu(fe->id2.i_chain.cl_cpg) !=
  265. ocfs2_group_bitmap_size(osb->sb, 0,
  266. osb->s_feature_incompat) * 8) {
  267. mlog(ML_ERROR, "The disk is too old and small. "
  268. "Force to do offline resize.");
  269. ret = -EINVAL;
  270. goto out_unlock;
  271. }
  272. first_new_cluster = le32_to_cpu(fe->i_clusters);
  273. lgd_blkno = ocfs2_which_cluster_group(main_bm_inode,
  274. first_new_cluster - 1);
  275. ret = ocfs2_read_group_descriptor(main_bm_inode, fe, lgd_blkno,
  276. &group_bh);
  277. if (ret < 0) {
  278. mlog_errno(ret);
  279. goto out_unlock;
  280. }
  281. group = (struct ocfs2_group_desc *)group_bh->b_data;
  282. cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc);
  283. if (le16_to_cpu(group->bg_bits) / cl_bpc + new_clusters >
  284. le16_to_cpu(fe->id2.i_chain.cl_cpg)) {
  285. ret = -EINVAL;
  286. goto out_unlock;
  287. }
  288. trace_ocfs2_group_extend(
  289. (unsigned long long)le64_to_cpu(group->bg_blkno), new_clusters);
  290. handle = ocfs2_start_trans(osb, OCFS2_GROUP_EXTEND_CREDITS);
  291. if (IS_ERR(handle)) {
  292. mlog_errno(PTR_ERR(handle));
  293. ret = -EINVAL;
  294. goto out_unlock;
  295. }
  296. /* update the last group descriptor and inode. */
  297. ret = ocfs2_update_last_group_and_inode(handle, main_bm_inode,
  298. main_bm_bh, group_bh,
  299. first_new_cluster,
  300. new_clusters);
  301. if (ret) {
  302. mlog_errno(ret);
  303. goto out_commit;
  304. }
  305. ocfs2_update_super_and_backups(main_bm_inode, new_clusters);
  306. out_commit:
  307. ocfs2_commit_trans(osb, handle);
  308. out_unlock:
  309. brelse(group_bh);
  310. brelse(main_bm_bh);
  311. ocfs2_inode_unlock(main_bm_inode, 1);
  312. out_mutex:
  313. mutex_unlock(&main_bm_inode->i_mutex);
  314. iput(main_bm_inode);
  315. out:
  316. return ret;
  317. }
  318. static int ocfs2_check_new_group(struct inode *inode,
  319. struct ocfs2_dinode *di,
  320. struct ocfs2_new_group_input *input,
  321. struct buffer_head *group_bh)
  322. {
  323. int ret;
  324. struct ocfs2_group_desc *gd =
  325. (struct ocfs2_group_desc *)group_bh->b_data;
  326. u16 cl_bpc = le16_to_cpu(di->id2.i_chain.cl_bpc);
  327. ret = ocfs2_check_group_descriptor(inode->i_sb, di, group_bh);
  328. if (ret)
  329. goto out;
  330. ret = -EINVAL;
  331. if (le16_to_cpu(gd->bg_chain) != input->chain)
  332. mlog(ML_ERROR, "Group descriptor # %llu has bad chain %u "
  333. "while input has %u set.\n",
  334. (unsigned long long)le64_to_cpu(gd->bg_blkno),
  335. le16_to_cpu(gd->bg_chain), input->chain);
  336. else if (le16_to_cpu(gd->bg_bits) != input->clusters * cl_bpc)
  337. mlog(ML_ERROR, "Group descriptor # %llu has bit count %u but "
  338. "input has %u clusters set\n",
  339. (unsigned long long)le64_to_cpu(gd->bg_blkno),
  340. le16_to_cpu(gd->bg_bits), input->clusters);
  341. else if (le16_to_cpu(gd->bg_free_bits_count) != input->frees * cl_bpc)
  342. mlog(ML_ERROR, "Group descriptor # %llu has free bit count %u "
  343. "but it should have %u set\n",
  344. (unsigned long long)le64_to_cpu(gd->bg_blkno),
  345. le16_to_cpu(gd->bg_bits),
  346. input->frees * cl_bpc);
  347. else
  348. ret = 0;
  349. out:
  350. return ret;
  351. }
  352. static int ocfs2_verify_group_and_input(struct inode *inode,
  353. struct ocfs2_dinode *di,
  354. struct ocfs2_new_group_input *input,
  355. struct buffer_head *group_bh)
  356. {
  357. u16 cl_count = le16_to_cpu(di->id2.i_chain.cl_count);
  358. u16 cl_cpg = le16_to_cpu(di->id2.i_chain.cl_cpg);
  359. u16 next_free = le16_to_cpu(di->id2.i_chain.cl_next_free_rec);
  360. u32 cluster = ocfs2_blocks_to_clusters(inode->i_sb, input->group);
  361. u32 total_clusters = le32_to_cpu(di->i_clusters);
  362. int ret = -EINVAL;
  363. if (cluster < total_clusters)
  364. mlog(ML_ERROR, "add a group which is in the current volume.\n");
  365. else if (input->chain >= cl_count)
  366. mlog(ML_ERROR, "input chain exceeds the limit.\n");
  367. else if (next_free != cl_count && next_free != input->chain)
  368. mlog(ML_ERROR,
  369. "the add group should be in chain %u\n", next_free);
  370. else if (total_clusters + input->clusters < total_clusters)
  371. mlog(ML_ERROR, "add group's clusters overflow.\n");
  372. else if (input->clusters > cl_cpg)
  373. mlog(ML_ERROR, "the cluster exceeds the maximum of a group\n");
  374. else if (input->frees > input->clusters)
  375. mlog(ML_ERROR, "the free cluster exceeds the total clusters\n");
  376. else if (total_clusters % cl_cpg != 0)
  377. mlog(ML_ERROR,
  378. "the last group isn't full. Use group extend first.\n");
  379. else if (input->group != ocfs2_which_cluster_group(inode, cluster))
  380. mlog(ML_ERROR, "group blkno is invalid\n");
  381. else if ((ret = ocfs2_check_new_group(inode, di, input, group_bh)))
  382. mlog(ML_ERROR, "group descriptor check failed.\n");
  383. else
  384. ret = 0;
  385. return ret;
  386. }
  387. /* Add a new group descriptor to global_bitmap. */
  388. int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
  389. {
  390. int ret;
  391. handle_t *handle;
  392. struct buffer_head *main_bm_bh = NULL;
  393. struct inode *main_bm_inode = NULL;
  394. struct ocfs2_dinode *fe = NULL;
  395. struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
  396. struct buffer_head *group_bh = NULL;
  397. struct ocfs2_group_desc *group = NULL;
  398. struct ocfs2_chain_list *cl;
  399. struct ocfs2_chain_rec *cr;
  400. u16 cl_bpc;
  401. u64 bg_ptr;
  402. if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
  403. return -EROFS;
  404. main_bm_inode = ocfs2_get_system_file_inode(osb,
  405. GLOBAL_BITMAP_SYSTEM_INODE,
  406. OCFS2_INVALID_SLOT);
  407. if (!main_bm_inode) {
  408. ret = -EINVAL;
  409. mlog_errno(ret);
  410. goto out;
  411. }
  412. mutex_lock(&main_bm_inode->i_mutex);
  413. ret = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 1);
  414. if (ret < 0) {
  415. mlog_errno(ret);
  416. goto out_mutex;
  417. }
  418. fe = (struct ocfs2_dinode *)main_bm_bh->b_data;
  419. if (le16_to_cpu(fe->id2.i_chain.cl_cpg) !=
  420. ocfs2_group_bitmap_size(osb->sb, 0,
  421. osb->s_feature_incompat) * 8) {
  422. mlog(ML_ERROR, "The disk is too old and small."
  423. " Force to do offline resize.");
  424. ret = -EINVAL;
  425. goto out_unlock;
  426. }
  427. ret = ocfs2_read_blocks_sync(osb, input->group, 1, &group_bh);
  428. if (ret < 0) {
  429. mlog(ML_ERROR, "Can't read the group descriptor # %llu "
  430. "from the device.", (unsigned long long)input->group);
  431. goto out_unlock;
  432. }
  433. ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), group_bh);
  434. ret = ocfs2_verify_group_and_input(main_bm_inode, fe, input, group_bh);
  435. if (ret) {
  436. mlog_errno(ret);
  437. goto out_free_group_bh;
  438. }
  439. trace_ocfs2_group_add((unsigned long long)input->group,
  440. input->chain, input->clusters, input->frees);
  441. handle = ocfs2_start_trans(osb, OCFS2_GROUP_ADD_CREDITS);
  442. if (IS_ERR(handle)) {
  443. mlog_errno(PTR_ERR(handle));
  444. ret = -EINVAL;
  445. goto out_free_group_bh;
  446. }
  447. cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc);
  448. cl = &fe->id2.i_chain;
  449. cr = &cl->cl_recs[input->chain];
  450. ret = ocfs2_journal_access_gd(handle, INODE_CACHE(main_bm_inode),
  451. group_bh, OCFS2_JOURNAL_ACCESS_WRITE);
  452. if (ret < 0) {
  453. mlog_errno(ret);
  454. goto out_commit;
  455. }
  456. group = (struct ocfs2_group_desc *)group_bh->b_data;
  457. bg_ptr = le64_to_cpu(group->bg_next_group);
  458. group->bg_next_group = cr->c_blkno;
  459. ocfs2_journal_dirty(handle, group_bh);
  460. ret = ocfs2_journal_access_di(handle, INODE_CACHE(main_bm_inode),
  461. main_bm_bh, OCFS2_JOURNAL_ACCESS_WRITE);
  462. if (ret < 0) {
  463. group->bg_next_group = cpu_to_le64(bg_ptr);
  464. mlog_errno(ret);
  465. goto out_commit;
  466. }
  467. if (input->chain == le16_to_cpu(cl->cl_next_free_rec)) {
  468. le16_add_cpu(&cl->cl_next_free_rec, 1);
  469. memset(cr, 0, sizeof(struct ocfs2_chain_rec));
  470. }
  471. cr->c_blkno = cpu_to_le64(input->group);
  472. le32_add_cpu(&cr->c_total, input->clusters * cl_bpc);
  473. le32_add_cpu(&cr->c_free, input->frees * cl_bpc);
  474. le32_add_cpu(&fe->id1.bitmap1.i_total, input->clusters *cl_bpc);
  475. le32_add_cpu(&fe->id1.bitmap1.i_used,
  476. (input->clusters - input->frees) * cl_bpc);
  477. le32_add_cpu(&fe->i_clusters, input->clusters);
  478. ocfs2_journal_dirty(handle, main_bm_bh);
  479. spin_lock(&OCFS2_I(main_bm_inode)->ip_lock);
  480. OCFS2_I(main_bm_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
  481. le64_add_cpu(&fe->i_size, (u64)input->clusters << osb->s_clustersize_bits);
  482. spin_unlock(&OCFS2_I(main_bm_inode)->ip_lock);
  483. i_size_write(main_bm_inode, le64_to_cpu(fe->i_size));
  484. ocfs2_update_super_and_backups(main_bm_inode, input->clusters);
  485. out_commit:
  486. ocfs2_commit_trans(osb, handle);
  487. out_free_group_bh:
  488. brelse(group_bh);
  489. out_unlock:
  490. brelse(main_bm_bh);
  491. ocfs2_inode_unlock(main_bm_inode, 1);
  492. out_mutex:
  493. mutex_unlock(&main_bm_inode->i_mutex);
  494. iput(main_bm_inode);
  495. out:
  496. return ret;
  497. }