resize.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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(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(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_block(main_bm_inode, lgd_blkno, &group_bh);
  286. if (ret < 0) {
  287. mlog_errno(ret);
  288. goto out_unlock;
  289. }
  290. group = (struct ocfs2_group_desc *)group_bh->b_data;
  291. ret = ocfs2_check_group_descriptor(inode->i_sb, fe, group);
  292. if (ret) {
  293. mlog_errno(ret);
  294. goto out_unlock;
  295. }
  296. cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc);
  297. if (le16_to_cpu(group->bg_bits) / cl_bpc + new_clusters >
  298. le16_to_cpu(fe->id2.i_chain.cl_cpg)) {
  299. ret = -EINVAL;
  300. goto out_unlock;
  301. }
  302. mlog(0, "extend the last group at %llu, new clusters = %d\n",
  303. (unsigned long long)le64_to_cpu(group->bg_blkno), new_clusters);
  304. handle = ocfs2_start_trans(osb, OCFS2_GROUP_EXTEND_CREDITS);
  305. if (IS_ERR(handle)) {
  306. mlog_errno(PTR_ERR(handle));
  307. ret = -EINVAL;
  308. goto out_unlock;
  309. }
  310. /* update the last group descriptor and inode. */
  311. ret = ocfs2_update_last_group_and_inode(handle, main_bm_inode,
  312. main_bm_bh, group_bh,
  313. first_new_cluster,
  314. new_clusters);
  315. if (ret) {
  316. mlog_errno(ret);
  317. goto out_commit;
  318. }
  319. ocfs2_update_super_and_backups(main_bm_inode, new_clusters);
  320. out_commit:
  321. ocfs2_commit_trans(osb, handle);
  322. out_unlock:
  323. brelse(group_bh);
  324. brelse(main_bm_bh);
  325. ocfs2_inode_unlock(main_bm_inode, 1);
  326. out_mutex:
  327. mutex_unlock(&main_bm_inode->i_mutex);
  328. iput(main_bm_inode);
  329. out:
  330. mlog_exit_void();
  331. return ret;
  332. }
  333. static int ocfs2_check_new_group(struct inode *inode,
  334. struct ocfs2_dinode *di,
  335. struct ocfs2_new_group_input *input,
  336. struct buffer_head *group_bh)
  337. {
  338. int ret;
  339. struct ocfs2_group_desc *gd =
  340. (struct ocfs2_group_desc *)group_bh->b_data;
  341. u16 cl_bpc = le16_to_cpu(di->id2.i_chain.cl_bpc);
  342. ret = ocfs2_validate_group_descriptor(inode->i_sb, di, gd, 1);
  343. if (ret)
  344. goto out;
  345. ret = -EINVAL;
  346. if (le16_to_cpu(gd->bg_chain) != input->chain)
  347. mlog(ML_ERROR, "Group descriptor # %llu has bad chain %u "
  348. "while input has %u set.\n",
  349. (unsigned long long)le64_to_cpu(gd->bg_blkno),
  350. le16_to_cpu(gd->bg_chain), input->chain);
  351. else if (le16_to_cpu(gd->bg_bits) != input->clusters * cl_bpc)
  352. mlog(ML_ERROR, "Group descriptor # %llu has bit count %u but "
  353. "input has %u clusters set\n",
  354. (unsigned long long)le64_to_cpu(gd->bg_blkno),
  355. le16_to_cpu(gd->bg_bits), input->clusters);
  356. else if (le16_to_cpu(gd->bg_free_bits_count) != input->frees * cl_bpc)
  357. mlog(ML_ERROR, "Group descriptor # %llu has free bit count %u "
  358. "but it should have %u set\n",
  359. (unsigned long long)le64_to_cpu(gd->bg_blkno),
  360. le16_to_cpu(gd->bg_bits),
  361. input->frees * cl_bpc);
  362. else
  363. ret = 0;
  364. out:
  365. return ret;
  366. }
  367. static int ocfs2_verify_group_and_input(struct inode *inode,
  368. struct ocfs2_dinode *di,
  369. struct ocfs2_new_group_input *input,
  370. struct buffer_head *group_bh)
  371. {
  372. u16 cl_count = le16_to_cpu(di->id2.i_chain.cl_count);
  373. u16 cl_cpg = le16_to_cpu(di->id2.i_chain.cl_cpg);
  374. u16 next_free = le16_to_cpu(di->id2.i_chain.cl_next_free_rec);
  375. u32 cluster = ocfs2_blocks_to_clusters(inode->i_sb, input->group);
  376. u32 total_clusters = le32_to_cpu(di->i_clusters);
  377. int ret = -EINVAL;
  378. if (cluster < total_clusters)
  379. mlog(ML_ERROR, "add a group which is in the current volume.\n");
  380. else if (input->chain >= cl_count)
  381. mlog(ML_ERROR, "input chain exceeds the limit.\n");
  382. else if (next_free != cl_count && next_free != input->chain)
  383. mlog(ML_ERROR,
  384. "the add group should be in chain %u\n", next_free);
  385. else if (total_clusters + input->clusters < total_clusters)
  386. mlog(ML_ERROR, "add group's clusters overflow.\n");
  387. else if (input->clusters > cl_cpg)
  388. mlog(ML_ERROR, "the cluster exceeds the maximum of a group\n");
  389. else if (input->frees > input->clusters)
  390. mlog(ML_ERROR, "the free cluster exceeds the total clusters\n");
  391. else if (total_clusters % cl_cpg != 0)
  392. mlog(ML_ERROR,
  393. "the last group isn't full. Use group extend first.\n");
  394. else if (input->group != ocfs2_which_cluster_group(inode, cluster))
  395. mlog(ML_ERROR, "group blkno is invalid\n");
  396. else if ((ret = ocfs2_check_new_group(inode, di, input, group_bh)))
  397. mlog(ML_ERROR, "group descriptor check failed.\n");
  398. else
  399. ret = 0;
  400. return ret;
  401. }
  402. /* Add a new group descriptor to global_bitmap. */
  403. int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
  404. {
  405. int ret;
  406. handle_t *handle;
  407. struct buffer_head *main_bm_bh = NULL;
  408. struct inode *main_bm_inode = NULL;
  409. struct ocfs2_dinode *fe = NULL;
  410. struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
  411. struct buffer_head *group_bh = NULL;
  412. struct ocfs2_group_desc *group = NULL;
  413. struct ocfs2_chain_list *cl;
  414. struct ocfs2_chain_rec *cr;
  415. u16 cl_bpc;
  416. mlog_entry_void();
  417. if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
  418. return -EROFS;
  419. main_bm_inode = ocfs2_get_system_file_inode(osb,
  420. GLOBAL_BITMAP_SYSTEM_INODE,
  421. OCFS2_INVALID_SLOT);
  422. if (!main_bm_inode) {
  423. ret = -EINVAL;
  424. mlog_errno(ret);
  425. goto out;
  426. }
  427. mutex_lock(&main_bm_inode->i_mutex);
  428. ret = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 1);
  429. if (ret < 0) {
  430. mlog_errno(ret);
  431. goto out_mutex;
  432. }
  433. fe = (struct ocfs2_dinode *)main_bm_bh->b_data;
  434. if (le16_to_cpu(fe->id2.i_chain.cl_cpg) !=
  435. ocfs2_group_bitmap_size(osb->sb) * 8) {
  436. mlog(ML_ERROR, "The disk is too old and small."
  437. " Force to do offline resize.");
  438. ret = -EINVAL;
  439. goto out_unlock;
  440. }
  441. ret = ocfs2_read_blocks_sync(osb, input->group, 1, &group_bh);
  442. if (ret < 0) {
  443. mlog(ML_ERROR, "Can't read the group descriptor # %llu "
  444. "from the device.", (unsigned long long)input->group);
  445. goto out_unlock;
  446. }
  447. ocfs2_set_new_buffer_uptodate(inode, group_bh);
  448. ret = ocfs2_verify_group_and_input(main_bm_inode, fe, input, group_bh);
  449. if (ret) {
  450. mlog_errno(ret);
  451. goto out_unlock;
  452. }
  453. mlog(0, "Add a new group %llu in chain = %u, length = %u\n",
  454. (unsigned long long)input->group, input->chain, input->clusters);
  455. handle = ocfs2_start_trans(osb, OCFS2_GROUP_ADD_CREDITS);
  456. if (IS_ERR(handle)) {
  457. mlog_errno(PTR_ERR(handle));
  458. ret = -EINVAL;
  459. goto out_unlock;
  460. }
  461. cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc);
  462. cl = &fe->id2.i_chain;
  463. cr = &cl->cl_recs[input->chain];
  464. ret = ocfs2_journal_access(handle, main_bm_inode, group_bh,
  465. OCFS2_JOURNAL_ACCESS_WRITE);
  466. if (ret < 0) {
  467. mlog_errno(ret);
  468. goto out_commit;
  469. }
  470. group = (struct ocfs2_group_desc *)group_bh->b_data;
  471. group->bg_next_group = cr->c_blkno;
  472. ret = ocfs2_journal_dirty(handle, group_bh);
  473. if (ret < 0) {
  474. mlog_errno(ret);
  475. goto out_commit;
  476. }
  477. ret = ocfs2_journal_access(handle, main_bm_inode, main_bm_bh,
  478. OCFS2_JOURNAL_ACCESS_WRITE);
  479. if (ret < 0) {
  480. mlog_errno(ret);
  481. goto out_commit;
  482. }
  483. if (input->chain == le16_to_cpu(cl->cl_next_free_rec)) {
  484. le16_add_cpu(&cl->cl_next_free_rec, 1);
  485. memset(cr, 0, sizeof(struct ocfs2_chain_rec));
  486. }
  487. cr->c_blkno = cpu_to_le64(input->group);
  488. le32_add_cpu(&cr->c_total, input->clusters * cl_bpc);
  489. le32_add_cpu(&cr->c_free, input->frees * cl_bpc);
  490. le32_add_cpu(&fe->id1.bitmap1.i_total, input->clusters *cl_bpc);
  491. le32_add_cpu(&fe->id1.bitmap1.i_used,
  492. (input->clusters - input->frees) * cl_bpc);
  493. le32_add_cpu(&fe->i_clusters, input->clusters);
  494. ocfs2_journal_dirty(handle, main_bm_bh);
  495. spin_lock(&OCFS2_I(main_bm_inode)->ip_lock);
  496. OCFS2_I(main_bm_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
  497. le64_add_cpu(&fe->i_size, input->clusters << osb->s_clustersize_bits);
  498. spin_unlock(&OCFS2_I(main_bm_inode)->ip_lock);
  499. i_size_write(main_bm_inode, le64_to_cpu(fe->i_size));
  500. ocfs2_update_super_and_backups(main_bm_inode, input->clusters);
  501. out_commit:
  502. ocfs2_commit_trans(osb, handle);
  503. out_unlock:
  504. brelse(group_bh);
  505. brelse(main_bm_bh);
  506. ocfs2_inode_unlock(main_bm_inode, 1);
  507. out_mutex:
  508. mutex_unlock(&main_bm_inode->i_mutex);
  509. iput(main_bm_inode);
  510. out:
  511. mlog_exit_void();
  512. return ret;
  513. }