resize.c 16 KB

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