inode.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  1. /* -*- mode: c; c-basic-offset: 8; -*-
  2. * vim: noexpandtab sw=8 ts=8 sts=0:
  3. *
  4. * inode.c
  5. *
  6. * vfs' aops, fops, dops and iops
  7. *
  8. * 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. */
  25. #include <linux/fs.h>
  26. #include <linux/types.h>
  27. #include <linux/slab.h>
  28. #include <linux/highmem.h>
  29. #include <linux/pagemap.h>
  30. #include <linux/smp_lock.h>
  31. #include <asm/byteorder.h>
  32. #define MLOG_MASK_PREFIX ML_INODE
  33. #include <cluster/masklog.h>
  34. #include "ocfs2.h"
  35. #include "alloc.h"
  36. #include "dlmglue.h"
  37. #include "extent_map.h"
  38. #include "file.h"
  39. #include "heartbeat.h"
  40. #include "inode.h"
  41. #include "journal.h"
  42. #include "namei.h"
  43. #include "suballoc.h"
  44. #include "super.h"
  45. #include "symlink.h"
  46. #include "sysfile.h"
  47. #include "uptodate.h"
  48. #include "vote.h"
  49. #include "buffer_head_io.h"
  50. #define OCFS2_FI_FLAG_NOWAIT 0x1
  51. #define OCFS2_FI_FLAG_DELETE 0x2
  52. struct ocfs2_find_inode_args
  53. {
  54. u64 fi_blkno;
  55. unsigned long fi_ino;
  56. unsigned int fi_flags;
  57. };
  58. static int ocfs2_read_locked_inode(struct inode *inode,
  59. struct ocfs2_find_inode_args *args);
  60. static int ocfs2_init_locked_inode(struct inode *inode, void *opaque);
  61. static int ocfs2_find_actor(struct inode *inode, void *opaque);
  62. static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
  63. struct inode *inode,
  64. struct buffer_head *fe_bh);
  65. struct inode *ocfs2_ilookup_for_vote(struct ocfs2_super *osb,
  66. u64 blkno,
  67. int delete_vote)
  68. {
  69. struct ocfs2_find_inode_args args;
  70. /* ocfs2_ilookup_for_vote should *only* be called from the
  71. * vote thread */
  72. BUG_ON(current != osb->vote_task);
  73. args.fi_blkno = blkno;
  74. args.fi_flags = OCFS2_FI_FLAG_NOWAIT;
  75. if (delete_vote)
  76. args.fi_flags |= OCFS2_FI_FLAG_DELETE;
  77. args.fi_ino = ino_from_blkno(osb->sb, blkno);
  78. return ilookup5(osb->sb, args.fi_ino, ocfs2_find_actor, &args);
  79. }
  80. struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno)
  81. {
  82. struct inode *inode = NULL;
  83. struct super_block *sb = osb->sb;
  84. struct ocfs2_find_inode_args args;
  85. mlog_entry("(blkno = %llu)\n", (unsigned long long)blkno);
  86. /* Ok. By now we've either got the offsets passed to us by the
  87. * caller, or we just pulled them off the bh. Lets do some
  88. * sanity checks to make sure they're OK. */
  89. if (blkno == 0) {
  90. inode = ERR_PTR(-EINVAL);
  91. mlog_errno(PTR_ERR(inode));
  92. goto bail;
  93. }
  94. args.fi_blkno = blkno;
  95. args.fi_flags = 0;
  96. args.fi_ino = ino_from_blkno(sb, blkno);
  97. inode = iget5_locked(sb, args.fi_ino, ocfs2_find_actor,
  98. ocfs2_init_locked_inode, &args);
  99. /* inode was *not* in the inode cache. 2.6.x requires
  100. * us to do our own read_inode call and unlock it
  101. * afterwards. */
  102. if (inode && inode->i_state & I_NEW) {
  103. mlog(0, "Inode was not in inode cache, reading it.\n");
  104. ocfs2_read_locked_inode(inode, &args);
  105. unlock_new_inode(inode);
  106. }
  107. if (inode == NULL) {
  108. inode = ERR_PTR(-ENOMEM);
  109. mlog_errno(PTR_ERR(inode));
  110. goto bail;
  111. }
  112. if (is_bad_inode(inode)) {
  113. iput(inode);
  114. inode = ERR_PTR(-ESTALE);
  115. mlog_errno(PTR_ERR(inode));
  116. goto bail;
  117. }
  118. bail:
  119. if (!IS_ERR(inode)) {
  120. mlog(0, "returning inode with number %llu\n",
  121. (unsigned long long)OCFS2_I(inode)->ip_blkno);
  122. mlog_exit_ptr(inode);
  123. } else
  124. mlog_errno(PTR_ERR(inode));
  125. return inode;
  126. }
  127. /*
  128. * here's how inodes get read from disk:
  129. * iget5_locked -> find_actor -> OCFS2_FIND_ACTOR
  130. * found? : return the in-memory inode
  131. * not found? : get_new_inode -> OCFS2_INIT_LOCKED_INODE
  132. */
  133. static int ocfs2_find_actor(struct inode *inode, void *opaque)
  134. {
  135. struct ocfs2_find_inode_args *args = NULL;
  136. struct ocfs2_inode_info *oi = OCFS2_I(inode);
  137. int ret = 0;
  138. mlog_entry("(0x%p, %lu, 0x%p)\n", inode, inode->i_ino, opaque);
  139. args = opaque;
  140. mlog_bug_on_msg(!inode, "No inode in find actor!\n");
  141. if (oi->ip_blkno != args->fi_blkno)
  142. goto bail;
  143. /* OCFS2_FI_FLAG_NOWAIT is *only* set from
  144. * ocfs2_ilookup_for_vote which won't create an inode for one
  145. * that isn't found. The vote thread which doesn't want to get
  146. * an inode which is in the process of going away - otherwise
  147. * the call to __wait_on_freeing_inode in find_inode_fast will
  148. * cause it to deadlock on an inode which may be waiting on a
  149. * vote (or lock release) in delete_inode */
  150. if ((args->fi_flags & OCFS2_FI_FLAG_NOWAIT) &&
  151. (inode->i_state & (I_FREEING|I_CLEAR))) {
  152. /* As stated above, we're not going to return an
  153. * inode. In the case of a delete vote, the voting
  154. * code is going to signal the other node to go
  155. * ahead. Mark that state here, so this freeing inode
  156. * has the state when it gets to delete_inode. */
  157. if (args->fi_flags & OCFS2_FI_FLAG_DELETE) {
  158. spin_lock(&oi->ip_lock);
  159. ocfs2_mark_inode_remotely_deleted(inode);
  160. spin_unlock(&oi->ip_lock);
  161. }
  162. goto bail;
  163. }
  164. ret = 1;
  165. bail:
  166. mlog_exit(ret);
  167. return ret;
  168. }
  169. /*
  170. * initialize the new inode, but don't do anything that would cause
  171. * us to sleep.
  172. * return 0 on success, 1 on failure
  173. */
  174. static int ocfs2_init_locked_inode(struct inode *inode, void *opaque)
  175. {
  176. struct ocfs2_find_inode_args *args = opaque;
  177. mlog_entry("inode = %p, opaque = %p\n", inode, opaque);
  178. inode->i_ino = args->fi_ino;
  179. OCFS2_I(inode)->ip_blkno = args->fi_blkno;
  180. mlog_exit(0);
  181. return 0;
  182. }
  183. int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
  184. int create_ino)
  185. {
  186. struct super_block *sb;
  187. struct ocfs2_super *osb;
  188. int status = -EINVAL;
  189. mlog_entry("(0x%p, size:%llu)\n", inode,
  190. (unsigned long long)fe->i_size);
  191. sb = inode->i_sb;
  192. osb = OCFS2_SB(sb);
  193. /* this means that read_inode cannot create a superblock inode
  194. * today. change if needed. */
  195. if (!OCFS2_IS_VALID_DINODE(fe) ||
  196. !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) {
  197. mlog(ML_ERROR, "Invalid dinode: i_ino=%lu, i_blkno=%llu, "
  198. "signature = %.*s, flags = 0x%x\n",
  199. inode->i_ino,
  200. (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
  201. fe->i_signature, le32_to_cpu(fe->i_flags));
  202. goto bail;
  203. }
  204. if (le32_to_cpu(fe->i_fs_generation) != osb->fs_generation) {
  205. mlog(ML_ERROR, "file entry generation does not match "
  206. "superblock! osb->fs_generation=%x, "
  207. "fe->i_fs_generation=%x\n",
  208. osb->fs_generation, le32_to_cpu(fe->i_fs_generation));
  209. goto bail;
  210. }
  211. inode->i_version = 1;
  212. inode->i_generation = le32_to_cpu(fe->i_generation);
  213. inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
  214. inode->i_mode = le16_to_cpu(fe->i_mode);
  215. inode->i_uid = le32_to_cpu(fe->i_uid);
  216. inode->i_gid = le32_to_cpu(fe->i_gid);
  217. inode->i_blksize = (u32)osb->s_clustersize;
  218. /* Fast symlinks will have i_size but no allocated clusters. */
  219. if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
  220. inode->i_blocks = 0;
  221. else
  222. inode->i_blocks =
  223. ocfs2_align_bytes_to_sectors(le64_to_cpu(fe->i_size));
  224. inode->i_mapping->a_ops = &ocfs2_aops;
  225. inode->i_flags |= S_NOATIME;
  226. inode->i_atime.tv_sec = le64_to_cpu(fe->i_atime);
  227. inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
  228. inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
  229. inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
  230. inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
  231. inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
  232. if (OCFS2_I(inode)->ip_blkno != le64_to_cpu(fe->i_blkno))
  233. mlog(ML_ERROR,
  234. "ip_blkno %llu != i_blkno %llu!\n",
  235. (unsigned long long)OCFS2_I(inode)->ip_blkno,
  236. (unsigned long long)fe->i_blkno);
  237. OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
  238. OCFS2_I(inode)->ip_orphaned_slot = OCFS2_INVALID_SLOT;
  239. if (create_ino)
  240. inode->i_ino = ino_from_blkno(inode->i_sb,
  241. le64_to_cpu(fe->i_blkno));
  242. mlog(0, "blkno = %llu, ino = %lu, create_ino = %s\n",
  243. (unsigned long long)fe->i_blkno, inode->i_ino, create_ino ? "true" : "false");
  244. inode->i_nlink = le16_to_cpu(fe->i_links_count);
  245. if (fe->i_flags & cpu_to_le32(OCFS2_LOCAL_ALLOC_FL)) {
  246. OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP;
  247. mlog(0, "local alloc inode: i_ino=%lu\n", inode->i_ino);
  248. } else if (fe->i_flags & cpu_to_le32(OCFS2_BITMAP_FL)) {
  249. OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP;
  250. } else if (fe->i_flags & cpu_to_le32(OCFS2_SUPER_BLOCK_FL)) {
  251. mlog(0, "superblock inode: i_ino=%lu\n", inode->i_ino);
  252. /* we can't actually hit this as read_inode can't
  253. * handle superblocks today ;-) */
  254. BUG();
  255. }
  256. switch (inode->i_mode & S_IFMT) {
  257. case S_IFREG:
  258. inode->i_fop = &ocfs2_fops;
  259. inode->i_op = &ocfs2_file_iops;
  260. i_size_write(inode, le64_to_cpu(fe->i_size));
  261. break;
  262. case S_IFDIR:
  263. inode->i_op = &ocfs2_dir_iops;
  264. inode->i_fop = &ocfs2_dops;
  265. i_size_write(inode, le64_to_cpu(fe->i_size));
  266. break;
  267. case S_IFLNK:
  268. if (ocfs2_inode_is_fast_symlink(inode))
  269. inode->i_op = &ocfs2_fast_symlink_inode_operations;
  270. else
  271. inode->i_op = &ocfs2_symlink_inode_operations;
  272. i_size_write(inode, le64_to_cpu(fe->i_size));
  273. break;
  274. default:
  275. inode->i_op = &ocfs2_special_file_iops;
  276. init_special_inode(inode, inode->i_mode,
  277. inode->i_rdev);
  278. break;
  279. }
  280. ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_rw_lockres,
  281. OCFS2_LOCK_TYPE_RW, inode);
  282. ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres,
  283. OCFS2_LOCK_TYPE_META, inode);
  284. ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_data_lockres,
  285. OCFS2_LOCK_TYPE_DATA, inode);
  286. status = 0;
  287. bail:
  288. mlog_exit(status);
  289. return status;
  290. }
  291. static int ocfs2_read_locked_inode(struct inode *inode,
  292. struct ocfs2_find_inode_args *args)
  293. {
  294. struct super_block *sb;
  295. struct ocfs2_super *osb;
  296. struct ocfs2_dinode *fe;
  297. struct buffer_head *bh = NULL;
  298. int status;
  299. int sysfile = 0;
  300. mlog_entry("(0x%p, 0x%p)\n", inode, args);
  301. status = -EINVAL;
  302. if (inode == NULL || inode->i_sb == NULL) {
  303. mlog(ML_ERROR, "bad inode\n");
  304. goto bail;
  305. }
  306. sb = inode->i_sb;
  307. osb = OCFS2_SB(sb);
  308. if (!args) {
  309. mlog(ML_ERROR, "bad inode args\n");
  310. make_bad_inode(inode);
  311. goto bail;
  312. }
  313. /* Read the FE off disk. This is safe because the kernel only
  314. * does one read_inode2 for a new inode, and if it doesn't
  315. * exist yet then nobody can be working on it! */
  316. status = ocfs2_read_block(osb, args->fi_blkno, &bh, 0, NULL);
  317. if (status < 0) {
  318. mlog_errno(status);
  319. make_bad_inode(inode);
  320. goto bail;
  321. }
  322. fe = (struct ocfs2_dinode *) bh->b_data;
  323. if (!OCFS2_IS_VALID_DINODE(fe)) {
  324. mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n",
  325. (unsigned long long)fe->i_blkno, 7, fe->i_signature);
  326. make_bad_inode(inode);
  327. goto bail;
  328. }
  329. if (fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL))
  330. sysfile = 1;
  331. if (S_ISCHR(le16_to_cpu(fe->i_mode)) ||
  332. S_ISBLK(le16_to_cpu(fe->i_mode)))
  333. inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
  334. status = -EINVAL;
  335. if (ocfs2_populate_inode(inode, fe, 0) < 0) {
  336. mlog(ML_ERROR, "populate failed! i_blkno=%llu, i_ino=%lu\n",
  337. (unsigned long long)fe->i_blkno, inode->i_ino);
  338. make_bad_inode(inode);
  339. goto bail;
  340. }
  341. BUG_ON(args->fi_blkno != le64_to_cpu(fe->i_blkno));
  342. if (sysfile)
  343. OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SYSTEM_FILE;
  344. status = 0;
  345. bail:
  346. if (args && bh)
  347. brelse(bh);
  348. mlog_exit(status);
  349. return status;
  350. }
  351. void ocfs2_sync_blockdev(struct super_block *sb)
  352. {
  353. sync_blockdev(sb->s_bdev);
  354. }
  355. static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
  356. struct inode *inode,
  357. struct buffer_head *fe_bh)
  358. {
  359. int status = 0;
  360. struct ocfs2_journal_handle *handle = NULL;
  361. struct ocfs2_truncate_context *tc = NULL;
  362. struct ocfs2_dinode *fe;
  363. mlog_entry_void();
  364. fe = (struct ocfs2_dinode *) fe_bh->b_data;
  365. /* zero allocation, zero truncate :) */
  366. if (!fe->i_clusters)
  367. goto bail;
  368. handle = ocfs2_start_trans(osb, handle, OCFS2_INODE_UPDATE_CREDITS);
  369. if (IS_ERR(handle)) {
  370. status = PTR_ERR(handle);
  371. handle = NULL;
  372. mlog_errno(status);
  373. goto bail;
  374. }
  375. status = ocfs2_set_inode_size(handle, inode, fe_bh, 0ULL);
  376. if (status < 0) {
  377. mlog_errno(status);
  378. goto bail;
  379. }
  380. ocfs2_commit_trans(handle);
  381. handle = NULL;
  382. status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc);
  383. if (status < 0) {
  384. mlog_errno(status);
  385. goto bail;
  386. }
  387. status = ocfs2_commit_truncate(osb, inode, fe_bh, tc);
  388. if (status < 0) {
  389. mlog_errno(status);
  390. goto bail;
  391. }
  392. bail:
  393. if (handle)
  394. ocfs2_commit_trans(handle);
  395. mlog_exit(status);
  396. return status;
  397. }
  398. static int ocfs2_remove_inode(struct inode *inode,
  399. struct buffer_head *di_bh,
  400. struct inode *orphan_dir_inode,
  401. struct buffer_head *orphan_dir_bh)
  402. {
  403. int status;
  404. struct inode *inode_alloc_inode = NULL;
  405. struct buffer_head *inode_alloc_bh = NULL;
  406. struct ocfs2_journal_handle *handle;
  407. struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
  408. struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
  409. inode_alloc_inode =
  410. ocfs2_get_system_file_inode(osb, INODE_ALLOC_SYSTEM_INODE,
  411. le16_to_cpu(di->i_suballoc_slot));
  412. if (!inode_alloc_inode) {
  413. status = -EEXIST;
  414. mlog_errno(status);
  415. goto bail;
  416. }
  417. mutex_lock(&inode_alloc_inode->i_mutex);
  418. status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1);
  419. if (status < 0) {
  420. mutex_unlock(&inode_alloc_inode->i_mutex);
  421. mlog_errno(status);
  422. goto bail;
  423. }
  424. handle = ocfs2_start_trans(osb, NULL, OCFS2_DELETE_INODE_CREDITS);
  425. if (IS_ERR(handle)) {
  426. status = PTR_ERR(handle);
  427. mlog_errno(status);
  428. goto bail_unlock;
  429. }
  430. status = ocfs2_orphan_del(osb, handle, orphan_dir_inode, inode,
  431. orphan_dir_bh);
  432. if (status < 0) {
  433. mlog_errno(status);
  434. goto bail_commit;
  435. }
  436. /* set the inodes dtime */
  437. status = ocfs2_journal_access(handle, inode, di_bh,
  438. OCFS2_JOURNAL_ACCESS_WRITE);
  439. if (status < 0) {
  440. mlog_errno(status);
  441. goto bail_commit;
  442. }
  443. di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec);
  444. le32_and_cpu(&di->i_flags, ~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL));
  445. status = ocfs2_journal_dirty(handle, di_bh);
  446. if (status < 0) {
  447. mlog_errno(status);
  448. goto bail_commit;
  449. }
  450. ocfs2_remove_from_cache(inode, di_bh);
  451. status = ocfs2_free_dinode(handle, inode_alloc_inode,
  452. inode_alloc_bh, di);
  453. if (status < 0)
  454. mlog_errno(status);
  455. bail_commit:
  456. ocfs2_commit_trans(handle);
  457. bail_unlock:
  458. ocfs2_meta_unlock(inode_alloc_inode, 1);
  459. mutex_unlock(&inode_alloc_inode->i_mutex);
  460. brelse(inode_alloc_bh);
  461. bail:
  462. iput(inode_alloc_inode);
  463. return status;
  464. }
  465. /*
  466. * Serialize with orphan dir recovery. If the process doing
  467. * recovery on this orphan dir does an iget() with the dir
  468. * i_mutex held, we'll deadlock here. Instead we detect this
  469. * and exit early - recovery will wipe this inode for us.
  470. */
  471. static int ocfs2_check_orphan_recovery_state(struct ocfs2_super *osb,
  472. int slot)
  473. {
  474. int ret = 0;
  475. spin_lock(&osb->osb_lock);
  476. if (ocfs2_node_map_test_bit(osb, &osb->osb_recovering_orphan_dirs, slot)) {
  477. mlog(0, "Recovery is happening on orphan dir %d, will skip "
  478. "this inode\n", slot);
  479. ret = -EDEADLK;
  480. goto out;
  481. }
  482. /* This signals to the orphan recovery process that it should
  483. * wait for us to handle the wipe. */
  484. osb->osb_orphan_wipes[slot]++;
  485. out:
  486. spin_unlock(&osb->osb_lock);
  487. return ret;
  488. }
  489. static void ocfs2_signal_wipe_completion(struct ocfs2_super *osb,
  490. int slot)
  491. {
  492. spin_lock(&osb->osb_lock);
  493. osb->osb_orphan_wipes[slot]--;
  494. spin_unlock(&osb->osb_lock);
  495. wake_up(&osb->osb_wipe_event);
  496. }
  497. static int ocfs2_wipe_inode(struct inode *inode,
  498. struct buffer_head *di_bh)
  499. {
  500. int status, orphaned_slot;
  501. struct inode *orphan_dir_inode = NULL;
  502. struct buffer_head *orphan_dir_bh = NULL;
  503. struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
  504. /* We've already voted on this so it should be readonly - no
  505. * spinlock needed. */
  506. orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot;
  507. status = ocfs2_check_orphan_recovery_state(osb, orphaned_slot);
  508. if (status)
  509. return status;
  510. orphan_dir_inode = ocfs2_get_system_file_inode(osb,
  511. ORPHAN_DIR_SYSTEM_INODE,
  512. orphaned_slot);
  513. if (!orphan_dir_inode) {
  514. status = -EEXIST;
  515. mlog_errno(status);
  516. goto bail;
  517. }
  518. /* Lock the orphan dir. The lock will be held for the entire
  519. * delete_inode operation. We do this now to avoid races with
  520. * recovery completion on other nodes. */
  521. mutex_lock(&orphan_dir_inode->i_mutex);
  522. status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1);
  523. if (status < 0) {
  524. mutex_unlock(&orphan_dir_inode->i_mutex);
  525. mlog_errno(status);
  526. goto bail;
  527. }
  528. /* we do this while holding the orphan dir lock because we
  529. * don't want recovery being run from another node to vote for
  530. * an inode delete on us -- this will result in two nodes
  531. * truncating the same file! */
  532. status = ocfs2_truncate_for_delete(osb, inode, di_bh);
  533. if (status < 0) {
  534. mlog_errno(status);
  535. goto bail_unlock_dir;
  536. }
  537. status = ocfs2_remove_inode(inode, di_bh, orphan_dir_inode,
  538. orphan_dir_bh);
  539. if (status < 0)
  540. mlog_errno(status);
  541. bail_unlock_dir:
  542. ocfs2_meta_unlock(orphan_dir_inode, 1);
  543. mutex_unlock(&orphan_dir_inode->i_mutex);
  544. brelse(orphan_dir_bh);
  545. bail:
  546. iput(orphan_dir_inode);
  547. ocfs2_signal_wipe_completion(osb, orphaned_slot);
  548. return status;
  549. }
  550. /* There is a series of simple checks that should be done before a
  551. * vote is even considered. Encapsulate those in this function. */
  552. static int ocfs2_inode_is_valid_to_delete(struct inode *inode)
  553. {
  554. int ret = 0;
  555. struct ocfs2_inode_info *oi = OCFS2_I(inode);
  556. struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
  557. /* We shouldn't be getting here for the root directory
  558. * inode.. */
  559. if (inode == osb->root_inode) {
  560. mlog(ML_ERROR, "Skipping delete of root inode.\n");
  561. goto bail;
  562. }
  563. /* If we're coming from process_vote we can't go into our own
  564. * voting [hello, deadlock city!], so unforuntately we just
  565. * have to skip deleting this guy. That's OK though because
  566. * the node who's doing the actual deleting should handle it
  567. * anyway. */
  568. if (current == osb->vote_task) {
  569. mlog(0, "Skipping delete of %lu because we're currently "
  570. "in process_vote\n", inode->i_ino);
  571. goto bail;
  572. }
  573. spin_lock(&oi->ip_lock);
  574. /* OCFS2 *never* deletes system files. This should technically
  575. * never get here as system file inodes should always have a
  576. * positive link count. */
  577. if (oi->ip_flags & OCFS2_INODE_SYSTEM_FILE) {
  578. mlog(ML_ERROR, "Skipping delete of system file %llu\n",
  579. (unsigned long long)oi->ip_blkno);
  580. goto bail_unlock;
  581. }
  582. /* If we have voted "yes" on the wipe of this inode for
  583. * another node, it will be marked here so we can safely skip
  584. * it. Recovery will cleanup any inodes we might inadvertantly
  585. * skip here. */
  586. if (oi->ip_flags & OCFS2_INODE_SKIP_DELETE) {
  587. mlog(0, "Skipping delete of %lu because another node "
  588. "has done this for us.\n", inode->i_ino);
  589. goto bail_unlock;
  590. }
  591. ret = 1;
  592. bail_unlock:
  593. spin_unlock(&oi->ip_lock);
  594. bail:
  595. return ret;
  596. }
  597. /* Query the cluster to determine whether we should wipe an inode from
  598. * disk or not.
  599. *
  600. * Requires the inode to have the cluster lock. */
  601. static int ocfs2_query_inode_wipe(struct inode *inode,
  602. struct buffer_head *di_bh,
  603. int *wipe)
  604. {
  605. int status = 0;
  606. struct ocfs2_inode_info *oi = OCFS2_I(inode);
  607. struct ocfs2_dinode *di;
  608. *wipe = 0;
  609. /* While we were waiting for the cluster lock in
  610. * ocfs2_delete_inode, another node might have asked to delete
  611. * the inode. Recheck our flags to catch this. */
  612. if (!ocfs2_inode_is_valid_to_delete(inode)) {
  613. mlog(0, "Skipping delete of %llu because flags changed\n",
  614. (unsigned long long)oi->ip_blkno);
  615. goto bail;
  616. }
  617. /* Now that we have an up to date inode, we can double check
  618. * the link count. */
  619. if (inode->i_nlink) {
  620. mlog(0, "Skipping delete of %llu because nlink = %u\n",
  621. (unsigned long long)oi->ip_blkno, inode->i_nlink);
  622. goto bail;
  623. }
  624. /* Do some basic inode verification... */
  625. di = (struct ocfs2_dinode *) di_bh->b_data;
  626. if (!(di->i_flags & cpu_to_le32(OCFS2_ORPHANED_FL))) {
  627. /* for lack of a better error? */
  628. status = -EEXIST;
  629. mlog(ML_ERROR,
  630. "Inode %llu (on-disk %llu) not orphaned! "
  631. "Disk flags 0x%x, inode flags 0x%x\n",
  632. (unsigned long long)oi->ip_blkno,
  633. (unsigned long long)di->i_blkno, di->i_flags,
  634. oi->ip_flags);
  635. goto bail;
  636. }
  637. /* has someone already deleted us?! baaad... */
  638. if (di->i_dtime) {
  639. status = -EEXIST;
  640. mlog_errno(status);
  641. goto bail;
  642. }
  643. status = ocfs2_request_delete_vote(inode);
  644. /* -EBUSY means that other nodes are still using the
  645. * inode. We're done here though, so avoid doing anything on
  646. * disk and let them worry about deleting it. */
  647. if (status == -EBUSY) {
  648. status = 0;
  649. mlog(0, "Skipping delete of %llu because it is in use on"
  650. "other nodes\n", (unsigned long long)oi->ip_blkno);
  651. goto bail;
  652. }
  653. if (status < 0) {
  654. mlog_errno(status);
  655. goto bail;
  656. }
  657. spin_lock(&oi->ip_lock);
  658. if (oi->ip_orphaned_slot == OCFS2_INVALID_SLOT) {
  659. /* Nobody knew which slot this inode was orphaned
  660. * into. This may happen during node death and
  661. * recovery knows how to clean it up so we can safely
  662. * ignore this inode for now on. */
  663. mlog(0, "Nobody knew where inode %llu was orphaned!\n",
  664. (unsigned long long)oi->ip_blkno);
  665. } else {
  666. *wipe = 1;
  667. mlog(0, "Inode %llu is ok to wipe from orphan dir %d\n",
  668. (unsigned long long)oi->ip_blkno, oi->ip_orphaned_slot);
  669. }
  670. spin_unlock(&oi->ip_lock);
  671. bail:
  672. return status;
  673. }
  674. /* Support function for ocfs2_delete_inode. Will help us keep the
  675. * inode data in a consistent state for clear_inode. Always truncates
  676. * pages, optionally sync's them first. */
  677. static void ocfs2_cleanup_delete_inode(struct inode *inode,
  678. int sync_data)
  679. {
  680. mlog(0, "Cleanup inode %llu, sync = %d\n",
  681. (unsigned long long)OCFS2_I(inode)->ip_blkno, sync_data);
  682. if (sync_data)
  683. write_inode_now(inode, 1);
  684. truncate_inode_pages(&inode->i_data, 0);
  685. }
  686. void ocfs2_delete_inode(struct inode *inode)
  687. {
  688. int wipe, status;
  689. sigset_t blocked, oldset;
  690. struct buffer_head *di_bh = NULL;
  691. mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino);
  692. if (is_bad_inode(inode)) {
  693. mlog(0, "Skipping delete of bad inode\n");
  694. goto bail;
  695. }
  696. if (!ocfs2_inode_is_valid_to_delete(inode)) {
  697. /* It's probably not necessary to truncate_inode_pages
  698. * here but we do it for safety anyway (it will most
  699. * likely be a no-op anyway) */
  700. ocfs2_cleanup_delete_inode(inode, 0);
  701. goto bail;
  702. }
  703. /* We want to block signals in delete_inode as the lock and
  704. * messaging paths may return us -ERESTARTSYS. Which would
  705. * cause us to exit early, resulting in inodes being orphaned
  706. * forever. */
  707. sigfillset(&blocked);
  708. status = sigprocmask(SIG_BLOCK, &blocked, &oldset);
  709. if (status < 0) {
  710. mlog_errno(status);
  711. ocfs2_cleanup_delete_inode(inode, 1);
  712. goto bail;
  713. }
  714. /* Lock down the inode. This gives us an up to date view of
  715. * it's metadata (for verification), and allows us to
  716. * serialize delete_inode votes.
  717. *
  718. * Even though we might be doing a truncate, we don't take the
  719. * allocation lock here as it won't be needed - nobody will
  720. * have the file open.
  721. */
  722. status = ocfs2_meta_lock(inode, NULL, &di_bh, 1);
  723. if (status < 0) {
  724. if (status != -ENOENT)
  725. mlog_errno(status);
  726. ocfs2_cleanup_delete_inode(inode, 0);
  727. goto bail_unblock;
  728. }
  729. /* Query the cluster. This will be the final decision made
  730. * before we go ahead and wipe the inode. */
  731. status = ocfs2_query_inode_wipe(inode, di_bh, &wipe);
  732. if (!wipe || status < 0) {
  733. /* Error and inode busy vote both mean we won't be
  734. * removing the inode, so they take almost the same
  735. * path. */
  736. if (status < 0)
  737. mlog_errno(status);
  738. /* Someone in the cluster has voted to not wipe this
  739. * inode, or it was never completely orphaned. Write
  740. * out the pages and exit now. */
  741. ocfs2_cleanup_delete_inode(inode, 1);
  742. goto bail_unlock_inode;
  743. }
  744. ocfs2_cleanup_delete_inode(inode, 0);
  745. status = ocfs2_wipe_inode(inode, di_bh);
  746. if (status < 0) {
  747. if (status != -EDEADLK)
  748. mlog_errno(status);
  749. goto bail_unlock_inode;
  750. }
  751. /* Mark the inode as successfully deleted. This is important
  752. * for ocfs2_clear_inode as it will check this flag and skip
  753. * any checkpointing work */
  754. OCFS2_I(inode)->ip_flags |= OCFS2_INODE_DELETED;
  755. bail_unlock_inode:
  756. ocfs2_meta_unlock(inode, 1);
  757. brelse(di_bh);
  758. bail_unblock:
  759. status = sigprocmask(SIG_SETMASK, &oldset, NULL);
  760. if (status < 0)
  761. mlog_errno(status);
  762. bail:
  763. clear_inode(inode);
  764. mlog_exit_void();
  765. }
  766. void ocfs2_clear_inode(struct inode *inode)
  767. {
  768. int status;
  769. struct ocfs2_inode_info *oi = OCFS2_I(inode);
  770. mlog_entry_void();
  771. if (!inode)
  772. goto bail;
  773. mlog(0, "Clearing inode: %llu, nlink = %u\n",
  774. (unsigned long long)OCFS2_I(inode)->ip_blkno, inode->i_nlink);
  775. mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL,
  776. "Inode=%lu\n", inode->i_ino);
  777. /* Do these before all the other work so that we don't bounce
  778. * the vote thread while waiting to destroy the locks. */
  779. ocfs2_mark_lockres_freeing(&oi->ip_rw_lockres);
  780. ocfs2_mark_lockres_freeing(&oi->ip_meta_lockres);
  781. ocfs2_mark_lockres_freeing(&oi->ip_data_lockres);
  782. /* We very well may get a clear_inode before all an inodes
  783. * metadata has hit disk. Of course, we can't drop any cluster
  784. * locks until the journal has finished with it. The only
  785. * exception here are successfully wiped inodes - their
  786. * metadata can now be considered to be part of the system
  787. * inodes from which it came. */
  788. if (!(OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED))
  789. ocfs2_checkpoint_inode(inode);
  790. mlog_bug_on_msg(!list_empty(&oi->ip_io_markers),
  791. "Clear inode of %llu, inode has io markers\n",
  792. (unsigned long long)oi->ip_blkno);
  793. ocfs2_extent_map_drop(inode, 0);
  794. ocfs2_extent_map_init(inode);
  795. status = ocfs2_drop_inode_locks(inode);
  796. if (status < 0)
  797. mlog_errno(status);
  798. ocfs2_lock_res_free(&oi->ip_rw_lockres);
  799. ocfs2_lock_res_free(&oi->ip_meta_lockres);
  800. ocfs2_lock_res_free(&oi->ip_data_lockres);
  801. ocfs2_metadata_cache_purge(inode);
  802. mlog_bug_on_msg(oi->ip_metadata_cache.ci_num_cached,
  803. "Clear inode of %llu, inode has %u cache items\n",
  804. (unsigned long long)oi->ip_blkno, oi->ip_metadata_cache.ci_num_cached);
  805. mlog_bug_on_msg(!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE),
  806. "Clear inode of %llu, inode has a bad flag\n",
  807. (unsigned long long)oi->ip_blkno);
  808. mlog_bug_on_msg(spin_is_locked(&oi->ip_lock),
  809. "Clear inode of %llu, inode is locked\n",
  810. (unsigned long long)oi->ip_blkno);
  811. mlog_bug_on_msg(!mutex_trylock(&oi->ip_io_mutex),
  812. "Clear inode of %llu, io_mutex is locked\n",
  813. (unsigned long long)oi->ip_blkno);
  814. mutex_unlock(&oi->ip_io_mutex);
  815. /*
  816. * down_trylock() returns 0, down_write_trylock() returns 1
  817. * kernel 1, world 0
  818. */
  819. mlog_bug_on_msg(!down_write_trylock(&oi->ip_alloc_sem),
  820. "Clear inode of %llu, alloc_sem is locked\n",
  821. (unsigned long long)oi->ip_blkno);
  822. up_write(&oi->ip_alloc_sem);
  823. mlog_bug_on_msg(oi->ip_open_count,
  824. "Clear inode of %llu has open count %d\n",
  825. (unsigned long long)oi->ip_blkno, oi->ip_open_count);
  826. mlog_bug_on_msg(!list_empty(&oi->ip_handle_list),
  827. "Clear inode of %llu has non empty handle list\n",
  828. (unsigned long long)oi->ip_blkno);
  829. mlog_bug_on_msg(oi->ip_handle,
  830. "Clear inode of %llu has non empty handle pointer\n",
  831. (unsigned long long)oi->ip_blkno);
  832. /* Clear all other flags. */
  833. oi->ip_flags = OCFS2_INODE_CACHE_INLINE;
  834. oi->ip_created_trans = 0;
  835. oi->ip_last_trans = 0;
  836. oi->ip_dir_start_lookup = 0;
  837. oi->ip_blkno = 0ULL;
  838. bail:
  839. mlog_exit_void();
  840. }
  841. /* Called under inode_lock, with no more references on the
  842. * struct inode, so it's safe here to check the flags field
  843. * and to manipulate i_nlink without any other locks. */
  844. void ocfs2_drop_inode(struct inode *inode)
  845. {
  846. struct ocfs2_inode_info *oi = OCFS2_I(inode);
  847. mlog_entry_void();
  848. mlog(0, "Drop inode %llu, nlink = %u, ip_flags = 0x%x\n",
  849. (unsigned long long)oi->ip_blkno, inode->i_nlink, oi->ip_flags);
  850. /* Testing ip_orphaned_slot here wouldn't work because we may
  851. * not have gotten a delete_inode vote from any other nodes
  852. * yet. */
  853. if (oi->ip_flags & OCFS2_INODE_MAYBE_ORPHANED) {
  854. mlog(0, "Inode was orphaned on another node, clearing nlink.\n");
  855. inode->i_nlink = 0;
  856. }
  857. generic_drop_inode(inode);
  858. mlog_exit_void();
  859. }
  860. /*
  861. * TODO: this should probably be merged into ocfs2_get_block
  862. *
  863. * However, you now need to pay attention to the cont_prepare_write()
  864. * stuff in ocfs2_get_block (that is, ocfs2_get_block pretty much
  865. * expects never to extend).
  866. */
  867. struct buffer_head *ocfs2_bread(struct inode *inode,
  868. int block, int *err, int reada)
  869. {
  870. struct buffer_head *bh = NULL;
  871. int tmperr;
  872. u64 p_blkno;
  873. int readflags = OCFS2_BH_CACHED;
  874. #if 0
  875. /* only turn this on if we know we can deal with read_block
  876. * returning nothing */
  877. if (reada)
  878. readflags |= OCFS2_BH_READAHEAD;
  879. #endif
  880. if (((u64)block << inode->i_sb->s_blocksize_bits) >=
  881. i_size_read(inode)) {
  882. BUG_ON(!reada);
  883. return NULL;
  884. }
  885. tmperr = ocfs2_extent_map_get_blocks(inode, block, 1,
  886. &p_blkno, NULL);
  887. if (tmperr < 0) {
  888. mlog_errno(tmperr);
  889. goto fail;
  890. }
  891. tmperr = ocfs2_read_block(OCFS2_SB(inode->i_sb), p_blkno, &bh,
  892. readflags, inode);
  893. if (tmperr < 0)
  894. goto fail;
  895. tmperr = 0;
  896. *err = 0;
  897. return bh;
  898. fail:
  899. if (bh) {
  900. brelse(bh);
  901. bh = NULL;
  902. }
  903. *err = -EIO;
  904. return NULL;
  905. }
  906. /*
  907. * This is called from our getattr.
  908. */
  909. int ocfs2_inode_revalidate(struct dentry *dentry)
  910. {
  911. struct inode *inode = dentry->d_inode;
  912. int status = 0;
  913. mlog_entry("(inode = 0x%p, ino = %llu)\n", inode,
  914. inode ? (unsigned long long)OCFS2_I(inode)->ip_blkno : 0ULL);
  915. if (!inode) {
  916. mlog(0, "eep, no inode!\n");
  917. status = -ENOENT;
  918. goto bail;
  919. }
  920. spin_lock(&OCFS2_I(inode)->ip_lock);
  921. if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) {
  922. spin_unlock(&OCFS2_I(inode)->ip_lock);
  923. mlog(0, "inode deleted!\n");
  924. status = -ENOENT;
  925. goto bail;
  926. }
  927. spin_unlock(&OCFS2_I(inode)->ip_lock);
  928. /* Let ocfs2_meta_lock do the work of updating our struct
  929. * inode for us. */
  930. status = ocfs2_meta_lock(inode, NULL, NULL, 0);
  931. if (status < 0) {
  932. if (status != -ENOENT)
  933. mlog_errno(status);
  934. goto bail;
  935. }
  936. ocfs2_meta_unlock(inode, 0);
  937. bail:
  938. mlog_exit(status);
  939. return status;
  940. }
  941. /*
  942. * Updates a disk inode from a
  943. * struct inode.
  944. * Only takes ip_lock.
  945. */
  946. int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle,
  947. struct inode *inode,
  948. struct buffer_head *bh)
  949. {
  950. int status;
  951. struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data;
  952. mlog_entry("(inode %llu)\n",
  953. (unsigned long long)OCFS2_I(inode)->ip_blkno);
  954. status = ocfs2_journal_access(handle, inode, bh,
  955. OCFS2_JOURNAL_ACCESS_WRITE);
  956. if (status < 0) {
  957. mlog_errno(status);
  958. goto leave;
  959. }
  960. spin_lock(&OCFS2_I(inode)->ip_lock);
  961. fe->i_clusters = cpu_to_le32(OCFS2_I(inode)->ip_clusters);
  962. spin_unlock(&OCFS2_I(inode)->ip_lock);
  963. fe->i_size = cpu_to_le64(i_size_read(inode));
  964. fe->i_links_count = cpu_to_le16(inode->i_nlink);
  965. fe->i_uid = cpu_to_le32(inode->i_uid);
  966. fe->i_gid = cpu_to_le32(inode->i_gid);
  967. fe->i_mode = cpu_to_le16(inode->i_mode);
  968. fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
  969. fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
  970. fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
  971. fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
  972. fe->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
  973. fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
  974. status = ocfs2_journal_dirty(handle, bh);
  975. if (status < 0)
  976. mlog_errno(status);
  977. status = 0;
  978. leave:
  979. mlog_exit(status);
  980. return status;
  981. }
  982. /*
  983. *
  984. * Updates a struct inode from a disk inode.
  985. * does no i/o, only takes ip_lock.
  986. */
  987. void ocfs2_refresh_inode(struct inode *inode,
  988. struct ocfs2_dinode *fe)
  989. {
  990. struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
  991. spin_lock(&OCFS2_I(inode)->ip_lock);
  992. OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
  993. i_size_write(inode, le64_to_cpu(fe->i_size));
  994. inode->i_nlink = le16_to_cpu(fe->i_links_count);
  995. inode->i_uid = le32_to_cpu(fe->i_uid);
  996. inode->i_gid = le32_to_cpu(fe->i_gid);
  997. inode->i_mode = le16_to_cpu(fe->i_mode);
  998. inode->i_blksize = (u32) osb->s_clustersize;
  999. if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
  1000. inode->i_blocks = 0;
  1001. else
  1002. inode->i_blocks = ocfs2_align_bytes_to_sectors(i_size_read(inode));
  1003. inode->i_atime.tv_sec = le64_to_cpu(fe->i_atime);
  1004. inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
  1005. inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
  1006. inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec);
  1007. inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime);
  1008. inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec);
  1009. spin_unlock(&OCFS2_I(inode)->ip_lock);
  1010. }