namei.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916
  1. /* -*- mode: c; c-basic-offset: 8; -*-
  2. * vim: noexpandtab sw=8 ts=8 sts=0:
  3. *
  4. * namei.c
  5. *
  6. * Create and rename file, directory, symlinks
  7. *
  8. * Copyright (C) 2002, 2004 Oracle. All rights reserved.
  9. *
  10. * Portions of this code from linux/fs/ext3/dir.c
  11. *
  12. * Copyright (C) 1992, 1993, 1994, 1995
  13. * Remy Card (card@masi.ibp.fr)
  14. * Laboratoire MASI - Institut Blaise pascal
  15. * Universite Pierre et Marie Curie (Paris VI)
  16. *
  17. * from
  18. *
  19. * linux/fs/minix/dir.c
  20. *
  21. * Copyright (C) 1991, 1992 Linux Torvalds
  22. *
  23. * This program is free software; you can redistribute it and/or
  24. * modify it under the terms of the GNU General Public
  25. * License as published by the Free Software Foundation; either
  26. * version 2 of the License, or (at your option) any later version.
  27. *
  28. * This program is distributed in the hope that it will be useful,
  29. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  30. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  31. * General Public License for more details.
  32. *
  33. * You should have received a copy of the GNU General Public
  34. * License along with this program; if not, write to the
  35. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  36. * Boston, MA 021110-1307, USA.
  37. */
  38. #include <linux/fs.h>
  39. #include <linux/types.h>
  40. #include <linux/slab.h>
  41. #include <linux/highmem.h>
  42. #define MLOG_MASK_PREFIX ML_NAMEI
  43. #include <cluster/masklog.h>
  44. #include "ocfs2.h"
  45. #include "alloc.h"
  46. #include "dcache.h"
  47. #include "dir.h"
  48. #include "dlmglue.h"
  49. #include "extent_map.h"
  50. #include "file.h"
  51. #include "inode.h"
  52. #include "journal.h"
  53. #include "namei.h"
  54. #include "suballoc.h"
  55. #include "super.h"
  56. #include "symlink.h"
  57. #include "sysfile.h"
  58. #include "uptodate.h"
  59. #include "xattr.h"
  60. #include "buffer_head_io.h"
  61. static int ocfs2_mknod_locked(struct ocfs2_super *osb,
  62. struct inode *dir,
  63. struct inode *inode,
  64. struct dentry *dentry,
  65. dev_t dev,
  66. struct buffer_head **new_fe_bh,
  67. struct buffer_head *parent_fe_bh,
  68. handle_t *handle,
  69. struct ocfs2_alloc_context *inode_ac);
  70. static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
  71. struct inode **ret_orphan_dir,
  72. struct inode *inode,
  73. char *name,
  74. struct buffer_head **de_bh);
  75. static int ocfs2_orphan_add(struct ocfs2_super *osb,
  76. handle_t *handle,
  77. struct inode *inode,
  78. struct ocfs2_dinode *fe,
  79. char *name,
  80. struct buffer_head *de_bh,
  81. struct inode *orphan_dir_inode);
  82. static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
  83. handle_t *handle,
  84. struct inode *inode,
  85. const char *symname);
  86. /* An orphan dir name is an 8 byte value, printed as a hex string */
  87. #define OCFS2_ORPHAN_NAMELEN ((int)(2 * sizeof(u64)))
  88. static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry,
  89. struct nameidata *nd)
  90. {
  91. int status;
  92. u64 blkno;
  93. struct inode *inode = NULL;
  94. struct dentry *ret;
  95. struct ocfs2_inode_info *oi;
  96. mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
  97. dentry->d_name.len, dentry->d_name.name);
  98. if (dentry->d_name.len > OCFS2_MAX_FILENAME_LEN) {
  99. ret = ERR_PTR(-ENAMETOOLONG);
  100. goto bail;
  101. }
  102. mlog(0, "find name %.*s in directory %llu\n", dentry->d_name.len,
  103. dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno);
  104. status = ocfs2_inode_lock(dir, NULL, 0);
  105. if (status < 0) {
  106. if (status != -ENOENT)
  107. mlog_errno(status);
  108. ret = ERR_PTR(status);
  109. goto bail;
  110. }
  111. status = ocfs2_lookup_ino_from_name(dir, dentry->d_name.name,
  112. dentry->d_name.len, &blkno);
  113. if (status < 0)
  114. goto bail_add;
  115. inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0);
  116. if (IS_ERR(inode)) {
  117. ret = ERR_PTR(-EACCES);
  118. goto bail_unlock;
  119. }
  120. oi = OCFS2_I(inode);
  121. /* Clear any orphaned state... If we were able to look up the
  122. * inode from a directory, it certainly can't be orphaned. We
  123. * might have the bad state from a node which intended to
  124. * orphan this inode but crashed before it could commit the
  125. * unlink. */
  126. spin_lock(&oi->ip_lock);
  127. oi->ip_flags &= ~OCFS2_INODE_MAYBE_ORPHANED;
  128. spin_unlock(&oi->ip_lock);
  129. bail_add:
  130. dentry->d_op = &ocfs2_dentry_ops;
  131. ret = d_splice_alias(inode, dentry);
  132. if (inode) {
  133. /*
  134. * If d_splice_alias() finds a DCACHE_DISCONNECTED
  135. * dentry, it will d_move() it on top of ourse. The
  136. * return value will indicate this however, so in
  137. * those cases, we switch them around for the locking
  138. * code.
  139. *
  140. * NOTE: This dentry already has ->d_op set from
  141. * ocfs2_get_parent() and ocfs2_get_dentry()
  142. */
  143. if (ret)
  144. dentry = ret;
  145. status = ocfs2_dentry_attach_lock(dentry, inode,
  146. OCFS2_I(dir)->ip_blkno);
  147. if (status) {
  148. mlog_errno(status);
  149. ret = ERR_PTR(status);
  150. goto bail_unlock;
  151. }
  152. }
  153. bail_unlock:
  154. /* Don't drop the cluster lock until *after* the d_add --
  155. * unlink on another node will message us to remove that
  156. * dentry under this lock so otherwise we can race this with
  157. * the downconvert thread and have a stale dentry. */
  158. ocfs2_inode_unlock(dir, 0);
  159. bail:
  160. mlog_exit_ptr(ret);
  161. return ret;
  162. }
  163. static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode)
  164. {
  165. struct inode *inode;
  166. inode = new_inode(dir->i_sb);
  167. if (!inode) {
  168. mlog(ML_ERROR, "new_inode failed!\n");
  169. return NULL;
  170. }
  171. /* populate as many fields early on as possible - many of
  172. * these are used by the support functions here and in
  173. * callers. */
  174. if (S_ISDIR(mode))
  175. inode->i_nlink = 2;
  176. else
  177. inode->i_nlink = 1;
  178. inode->i_uid = current_fsuid();
  179. if (dir->i_mode & S_ISGID) {
  180. inode->i_gid = dir->i_gid;
  181. if (S_ISDIR(mode))
  182. mode |= S_ISGID;
  183. } else
  184. inode->i_gid = current_fsgid();
  185. inode->i_mode = mode;
  186. return inode;
  187. }
  188. static int ocfs2_mknod(struct inode *dir,
  189. struct dentry *dentry,
  190. int mode,
  191. dev_t dev)
  192. {
  193. int status = 0;
  194. struct buffer_head *parent_fe_bh = NULL;
  195. handle_t *handle = NULL;
  196. struct ocfs2_super *osb;
  197. struct ocfs2_dinode *dirfe;
  198. struct buffer_head *new_fe_bh = NULL;
  199. struct buffer_head *de_bh = NULL;
  200. struct inode *inode = NULL;
  201. struct ocfs2_alloc_context *inode_ac = NULL;
  202. struct ocfs2_alloc_context *data_ac = NULL;
  203. mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
  204. (unsigned long)dev, dentry->d_name.len,
  205. dentry->d_name.name);
  206. /* get our super block */
  207. osb = OCFS2_SB(dir->i_sb);
  208. status = ocfs2_inode_lock(dir, &parent_fe_bh, 1);
  209. if (status < 0) {
  210. if (status != -ENOENT)
  211. mlog_errno(status);
  212. return status;
  213. }
  214. if (S_ISDIR(mode) && (dir->i_nlink >= OCFS2_LINK_MAX)) {
  215. status = -EMLINK;
  216. goto leave;
  217. }
  218. dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data;
  219. if (!dirfe->i_links_count) {
  220. /* can't make a file in a deleted directory. */
  221. status = -ENOENT;
  222. goto leave;
  223. }
  224. status = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
  225. dentry->d_name.len);
  226. if (status)
  227. goto leave;
  228. /* get a spot inside the dir. */
  229. status = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
  230. dentry->d_name.name,
  231. dentry->d_name.len, &de_bh);
  232. if (status < 0) {
  233. mlog_errno(status);
  234. goto leave;
  235. }
  236. /* reserve an inode spot */
  237. status = ocfs2_reserve_new_inode(osb, &inode_ac);
  238. if (status < 0) {
  239. if (status != -ENOSPC)
  240. mlog_errno(status);
  241. goto leave;
  242. }
  243. inode = ocfs2_get_init_inode(dir, mode);
  244. if (!inode) {
  245. status = -ENOMEM;
  246. mlog_errno(status);
  247. goto leave;
  248. }
  249. /* Reserve a cluster if creating an extent based directory. */
  250. if (S_ISDIR(mode) && !ocfs2_supports_inline_data(osb)) {
  251. status = ocfs2_reserve_clusters(osb, 1, &data_ac);
  252. if (status < 0) {
  253. if (status != -ENOSPC)
  254. mlog_errno(status);
  255. goto leave;
  256. }
  257. }
  258. handle = ocfs2_start_trans(osb, OCFS2_MKNOD_CREDITS);
  259. if (IS_ERR(handle)) {
  260. status = PTR_ERR(handle);
  261. handle = NULL;
  262. mlog_errno(status);
  263. goto leave;
  264. }
  265. /* do the real work now. */
  266. status = ocfs2_mknod_locked(osb, dir, inode, dentry, dev,
  267. &new_fe_bh, parent_fe_bh, handle,
  268. inode_ac);
  269. if (status < 0) {
  270. mlog_errno(status);
  271. goto leave;
  272. }
  273. if (S_ISDIR(mode)) {
  274. status = ocfs2_fill_new_dir(osb, handle, dir, inode,
  275. new_fe_bh, data_ac);
  276. if (status < 0) {
  277. mlog_errno(status);
  278. goto leave;
  279. }
  280. status = ocfs2_journal_access(handle, dir, parent_fe_bh,
  281. OCFS2_JOURNAL_ACCESS_WRITE);
  282. if (status < 0) {
  283. mlog_errno(status);
  284. goto leave;
  285. }
  286. le16_add_cpu(&dirfe->i_links_count, 1);
  287. status = ocfs2_journal_dirty(handle, parent_fe_bh);
  288. if (status < 0) {
  289. mlog_errno(status);
  290. goto leave;
  291. }
  292. inc_nlink(dir);
  293. }
  294. status = ocfs2_add_entry(handle, dentry, inode,
  295. OCFS2_I(inode)->ip_blkno, parent_fe_bh,
  296. de_bh);
  297. if (status < 0) {
  298. mlog_errno(status);
  299. goto leave;
  300. }
  301. status = ocfs2_dentry_attach_lock(dentry, inode,
  302. OCFS2_I(dir)->ip_blkno);
  303. if (status) {
  304. mlog_errno(status);
  305. goto leave;
  306. }
  307. insert_inode_hash(inode);
  308. dentry->d_op = &ocfs2_dentry_ops;
  309. d_instantiate(dentry, inode);
  310. status = 0;
  311. leave:
  312. if (handle)
  313. ocfs2_commit_trans(osb, handle);
  314. ocfs2_inode_unlock(dir, 1);
  315. if (status == -ENOSPC)
  316. mlog(0, "Disk is full\n");
  317. brelse(new_fe_bh);
  318. brelse(de_bh);
  319. brelse(parent_fe_bh);
  320. if ((status < 0) && inode) {
  321. clear_nlink(inode);
  322. iput(inode);
  323. }
  324. if (inode_ac)
  325. ocfs2_free_alloc_context(inode_ac);
  326. if (data_ac)
  327. ocfs2_free_alloc_context(data_ac);
  328. mlog_exit(status);
  329. return status;
  330. }
  331. static int ocfs2_mknod_locked(struct ocfs2_super *osb,
  332. struct inode *dir,
  333. struct inode *inode,
  334. struct dentry *dentry,
  335. dev_t dev,
  336. struct buffer_head **new_fe_bh,
  337. struct buffer_head *parent_fe_bh,
  338. handle_t *handle,
  339. struct ocfs2_alloc_context *inode_ac)
  340. {
  341. int status = 0;
  342. struct ocfs2_dinode *fe = NULL;
  343. struct ocfs2_extent_list *fel;
  344. u64 fe_blkno = 0;
  345. u16 suballoc_bit;
  346. mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry,
  347. inode->i_mode, (unsigned long)dev, dentry->d_name.len,
  348. dentry->d_name.name);
  349. *new_fe_bh = NULL;
  350. status = ocfs2_claim_new_inode(osb, handle, inode_ac, &suballoc_bit,
  351. &fe_blkno);
  352. if (status < 0) {
  353. mlog_errno(status);
  354. goto leave;
  355. }
  356. /* populate as many fields early on as possible - many of
  357. * these are used by the support functions here and in
  358. * callers. */
  359. inode->i_ino = ino_from_blkno(osb->sb, fe_blkno);
  360. OCFS2_I(inode)->ip_blkno = fe_blkno;
  361. spin_lock(&osb->osb_lock);
  362. inode->i_generation = osb->s_next_generation++;
  363. spin_unlock(&osb->osb_lock);
  364. *new_fe_bh = sb_getblk(osb->sb, fe_blkno);
  365. if (!*new_fe_bh) {
  366. status = -EIO;
  367. mlog_errno(status);
  368. goto leave;
  369. }
  370. ocfs2_set_new_buffer_uptodate(inode, *new_fe_bh);
  371. status = ocfs2_journal_access(handle, inode, *new_fe_bh,
  372. OCFS2_JOURNAL_ACCESS_CREATE);
  373. if (status < 0) {
  374. mlog_errno(status);
  375. goto leave;
  376. }
  377. fe = (struct ocfs2_dinode *) (*new_fe_bh)->b_data;
  378. memset(fe, 0, osb->sb->s_blocksize);
  379. fe->i_generation = cpu_to_le32(inode->i_generation);
  380. fe->i_fs_generation = cpu_to_le32(osb->fs_generation);
  381. fe->i_blkno = cpu_to_le64(fe_blkno);
  382. fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
  383. fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
  384. fe->i_uid = cpu_to_le32(inode->i_uid);
  385. fe->i_gid = cpu_to_le32(inode->i_gid);
  386. fe->i_mode = cpu_to_le16(inode->i_mode);
  387. if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
  388. fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
  389. fe->i_links_count = cpu_to_le16(inode->i_nlink);
  390. fe->i_last_eb_blk = 0;
  391. strcpy(fe->i_signature, OCFS2_INODE_SIGNATURE);
  392. le32_add_cpu(&fe->i_flags, OCFS2_VALID_FL);
  393. fe->i_atime = fe->i_ctime = fe->i_mtime =
  394. cpu_to_le64(CURRENT_TIME.tv_sec);
  395. fe->i_mtime_nsec = fe->i_ctime_nsec = fe->i_atime_nsec =
  396. cpu_to_le32(CURRENT_TIME.tv_nsec);
  397. fe->i_dtime = 0;
  398. /*
  399. * If supported, directories start with inline data.
  400. */
  401. if (S_ISDIR(inode->i_mode) && ocfs2_supports_inline_data(osb)) {
  402. u16 feat = le16_to_cpu(fe->i_dyn_features);
  403. fe->i_dyn_features = cpu_to_le16(feat | OCFS2_INLINE_DATA_FL);
  404. fe->id2.i_data.id_count = cpu_to_le16(ocfs2_max_inline_data(osb->sb));
  405. } else {
  406. fel = &fe->id2.i_list;
  407. fel->l_tree_depth = 0;
  408. fel->l_next_free_rec = 0;
  409. fel->l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(osb->sb));
  410. }
  411. status = ocfs2_journal_dirty(handle, *new_fe_bh);
  412. if (status < 0) {
  413. mlog_errno(status);
  414. goto leave;
  415. }
  416. if (ocfs2_populate_inode(inode, fe, 1) < 0) {
  417. mlog(ML_ERROR, "populate inode failed! bh->b_blocknr=%llu, "
  418. "i_blkno=%llu, i_ino=%lu\n",
  419. (unsigned long long)(*new_fe_bh)->b_blocknr,
  420. (unsigned long long)le64_to_cpu(fe->i_blkno),
  421. inode->i_ino);
  422. BUG();
  423. }
  424. ocfs2_inode_set_new(osb, inode);
  425. if (!ocfs2_mount_local(osb)) {
  426. status = ocfs2_create_new_inode_locks(inode);
  427. if (status < 0)
  428. mlog_errno(status);
  429. }
  430. status = 0; /* error in ocfs2_create_new_inode_locks is not
  431. * critical */
  432. leave:
  433. if (status < 0) {
  434. if (*new_fe_bh) {
  435. brelse(*new_fe_bh);
  436. *new_fe_bh = NULL;
  437. }
  438. }
  439. mlog_exit(status);
  440. return status;
  441. }
  442. static int ocfs2_mkdir(struct inode *dir,
  443. struct dentry *dentry,
  444. int mode)
  445. {
  446. int ret;
  447. mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, mode,
  448. dentry->d_name.len, dentry->d_name.name);
  449. ret = ocfs2_mknod(dir, dentry, mode | S_IFDIR, 0);
  450. mlog_exit(ret);
  451. return ret;
  452. }
  453. static int ocfs2_create(struct inode *dir,
  454. struct dentry *dentry,
  455. int mode,
  456. struct nameidata *nd)
  457. {
  458. int ret;
  459. mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, mode,
  460. dentry->d_name.len, dentry->d_name.name);
  461. ret = ocfs2_mknod(dir, dentry, mode | S_IFREG, 0);
  462. mlog_exit(ret);
  463. return ret;
  464. }
  465. static int ocfs2_link(struct dentry *old_dentry,
  466. struct inode *dir,
  467. struct dentry *dentry)
  468. {
  469. handle_t *handle;
  470. struct inode *inode = old_dentry->d_inode;
  471. int err;
  472. struct buffer_head *fe_bh = NULL;
  473. struct buffer_head *parent_fe_bh = NULL;
  474. struct buffer_head *de_bh = NULL;
  475. struct ocfs2_dinode *fe = NULL;
  476. struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
  477. mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino,
  478. old_dentry->d_name.len, old_dentry->d_name.name,
  479. dentry->d_name.len, dentry->d_name.name);
  480. if (S_ISDIR(inode->i_mode))
  481. return -EPERM;
  482. err = ocfs2_inode_lock(dir, &parent_fe_bh, 1);
  483. if (err < 0) {
  484. if (err != -ENOENT)
  485. mlog_errno(err);
  486. return err;
  487. }
  488. if (!dir->i_nlink) {
  489. err = -ENOENT;
  490. goto out;
  491. }
  492. err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
  493. dentry->d_name.len);
  494. if (err)
  495. goto out;
  496. err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
  497. dentry->d_name.name,
  498. dentry->d_name.len, &de_bh);
  499. if (err < 0) {
  500. mlog_errno(err);
  501. goto out;
  502. }
  503. err = ocfs2_inode_lock(inode, &fe_bh, 1);
  504. if (err < 0) {
  505. if (err != -ENOENT)
  506. mlog_errno(err);
  507. goto out;
  508. }
  509. fe = (struct ocfs2_dinode *) fe_bh->b_data;
  510. if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) {
  511. err = -EMLINK;
  512. goto out_unlock_inode;
  513. }
  514. handle = ocfs2_start_trans(osb, OCFS2_LINK_CREDITS);
  515. if (IS_ERR(handle)) {
  516. err = PTR_ERR(handle);
  517. handle = NULL;
  518. mlog_errno(err);
  519. goto out_unlock_inode;
  520. }
  521. err = ocfs2_journal_access(handle, inode, fe_bh,
  522. OCFS2_JOURNAL_ACCESS_WRITE);
  523. if (err < 0) {
  524. mlog_errno(err);
  525. goto out_commit;
  526. }
  527. inc_nlink(inode);
  528. inode->i_ctime = CURRENT_TIME;
  529. fe->i_links_count = cpu_to_le16(inode->i_nlink);
  530. fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
  531. fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
  532. err = ocfs2_journal_dirty(handle, fe_bh);
  533. if (err < 0) {
  534. le16_add_cpu(&fe->i_links_count, -1);
  535. drop_nlink(inode);
  536. mlog_errno(err);
  537. goto out_commit;
  538. }
  539. err = ocfs2_add_entry(handle, dentry, inode,
  540. OCFS2_I(inode)->ip_blkno,
  541. parent_fe_bh, de_bh);
  542. if (err) {
  543. le16_add_cpu(&fe->i_links_count, -1);
  544. drop_nlink(inode);
  545. mlog_errno(err);
  546. goto out_commit;
  547. }
  548. err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
  549. if (err) {
  550. mlog_errno(err);
  551. goto out_commit;
  552. }
  553. atomic_inc(&inode->i_count);
  554. dentry->d_op = &ocfs2_dentry_ops;
  555. d_instantiate(dentry, inode);
  556. out_commit:
  557. ocfs2_commit_trans(osb, handle);
  558. out_unlock_inode:
  559. ocfs2_inode_unlock(inode, 1);
  560. out:
  561. ocfs2_inode_unlock(dir, 1);
  562. brelse(de_bh);
  563. brelse(fe_bh);
  564. brelse(parent_fe_bh);
  565. mlog_exit(err);
  566. return err;
  567. }
  568. /*
  569. * Takes and drops an exclusive lock on the given dentry. This will
  570. * force other nodes to drop it.
  571. */
  572. static int ocfs2_remote_dentry_delete(struct dentry *dentry)
  573. {
  574. int ret;
  575. ret = ocfs2_dentry_lock(dentry, 1);
  576. if (ret)
  577. mlog_errno(ret);
  578. else
  579. ocfs2_dentry_unlock(dentry, 1);
  580. return ret;
  581. }
  582. static inline int inode_is_unlinkable(struct inode *inode)
  583. {
  584. if (S_ISDIR(inode->i_mode)) {
  585. if (inode->i_nlink == 2)
  586. return 1;
  587. return 0;
  588. }
  589. if (inode->i_nlink == 1)
  590. return 1;
  591. return 0;
  592. }
  593. static int ocfs2_unlink(struct inode *dir,
  594. struct dentry *dentry)
  595. {
  596. int status;
  597. int child_locked = 0;
  598. struct inode *inode = dentry->d_inode;
  599. struct inode *orphan_dir = NULL;
  600. struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
  601. u64 blkno;
  602. struct ocfs2_dinode *fe = NULL;
  603. struct buffer_head *fe_bh = NULL;
  604. struct buffer_head *parent_node_bh = NULL;
  605. handle_t *handle = NULL;
  606. struct ocfs2_dir_entry *dirent = NULL;
  607. struct buffer_head *dirent_bh = NULL;
  608. char orphan_name[OCFS2_ORPHAN_NAMELEN + 1];
  609. struct buffer_head *orphan_entry_bh = NULL;
  610. mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
  611. dentry->d_name.len, dentry->d_name.name);
  612. BUG_ON(dentry->d_parent->d_inode != dir);
  613. mlog(0, "ino = %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno);
  614. if (inode == osb->root_inode) {
  615. mlog(0, "Cannot delete the root directory\n");
  616. return -EPERM;
  617. }
  618. status = ocfs2_inode_lock(dir, &parent_node_bh, 1);
  619. if (status < 0) {
  620. if (status != -ENOENT)
  621. mlog_errno(status);
  622. return status;
  623. }
  624. status = ocfs2_find_files_on_disk(dentry->d_name.name,
  625. dentry->d_name.len, &blkno,
  626. dir, &dirent_bh, &dirent);
  627. if (status < 0) {
  628. if (status != -ENOENT)
  629. mlog_errno(status);
  630. goto leave;
  631. }
  632. if (OCFS2_I(inode)->ip_blkno != blkno) {
  633. status = -ENOENT;
  634. mlog(0, "ip_blkno %llu != dirent blkno %llu ip_flags = %x\n",
  635. (unsigned long long)OCFS2_I(inode)->ip_blkno,
  636. (unsigned long long)blkno, OCFS2_I(inode)->ip_flags);
  637. goto leave;
  638. }
  639. status = ocfs2_inode_lock(inode, &fe_bh, 1);
  640. if (status < 0) {
  641. if (status != -ENOENT)
  642. mlog_errno(status);
  643. goto leave;
  644. }
  645. child_locked = 1;
  646. if (S_ISDIR(inode->i_mode)) {
  647. if (!ocfs2_empty_dir(inode)) {
  648. status = -ENOTEMPTY;
  649. goto leave;
  650. } else if (inode->i_nlink != 2) {
  651. status = -ENOTEMPTY;
  652. goto leave;
  653. }
  654. }
  655. status = ocfs2_remote_dentry_delete(dentry);
  656. if (status < 0) {
  657. /* This remote delete should succeed under all normal
  658. * circumstances. */
  659. mlog_errno(status);
  660. goto leave;
  661. }
  662. if (inode_is_unlinkable(inode)) {
  663. status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, inode,
  664. orphan_name,
  665. &orphan_entry_bh);
  666. if (status < 0) {
  667. mlog_errno(status);
  668. goto leave;
  669. }
  670. }
  671. handle = ocfs2_start_trans(osb, OCFS2_UNLINK_CREDITS);
  672. if (IS_ERR(handle)) {
  673. status = PTR_ERR(handle);
  674. handle = NULL;
  675. mlog_errno(status);
  676. goto leave;
  677. }
  678. status = ocfs2_journal_access(handle, inode, fe_bh,
  679. OCFS2_JOURNAL_ACCESS_WRITE);
  680. if (status < 0) {
  681. mlog_errno(status);
  682. goto leave;
  683. }
  684. fe = (struct ocfs2_dinode *) fe_bh->b_data;
  685. if (inode_is_unlinkable(inode)) {
  686. status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name,
  687. orphan_entry_bh, orphan_dir);
  688. if (status < 0) {
  689. mlog_errno(status);
  690. goto leave;
  691. }
  692. }
  693. /* delete the name from the parent dir */
  694. status = ocfs2_delete_entry(handle, dir, dirent, dirent_bh);
  695. if (status < 0) {
  696. mlog_errno(status);
  697. goto leave;
  698. }
  699. if (S_ISDIR(inode->i_mode))
  700. drop_nlink(inode);
  701. drop_nlink(inode);
  702. fe->i_links_count = cpu_to_le16(inode->i_nlink);
  703. status = ocfs2_journal_dirty(handle, fe_bh);
  704. if (status < 0) {
  705. mlog_errno(status);
  706. goto leave;
  707. }
  708. dir->i_ctime = dir->i_mtime = CURRENT_TIME;
  709. if (S_ISDIR(inode->i_mode))
  710. drop_nlink(dir);
  711. status = ocfs2_mark_inode_dirty(handle, dir, parent_node_bh);
  712. if (status < 0) {
  713. mlog_errno(status);
  714. if (S_ISDIR(inode->i_mode))
  715. inc_nlink(dir);
  716. }
  717. leave:
  718. if (handle)
  719. ocfs2_commit_trans(osb, handle);
  720. if (child_locked)
  721. ocfs2_inode_unlock(inode, 1);
  722. ocfs2_inode_unlock(dir, 1);
  723. if (orphan_dir) {
  724. /* This was locked for us in ocfs2_prepare_orphan_dir() */
  725. ocfs2_inode_unlock(orphan_dir, 1);
  726. mutex_unlock(&orphan_dir->i_mutex);
  727. iput(orphan_dir);
  728. }
  729. brelse(fe_bh);
  730. brelse(dirent_bh);
  731. brelse(parent_node_bh);
  732. brelse(orphan_entry_bh);
  733. mlog_exit(status);
  734. return status;
  735. }
  736. /*
  737. * The only place this should be used is rename!
  738. * if they have the same id, then the 1st one is the only one locked.
  739. */
  740. static int ocfs2_double_lock(struct ocfs2_super *osb,
  741. struct buffer_head **bh1,
  742. struct inode *inode1,
  743. struct buffer_head **bh2,
  744. struct inode *inode2)
  745. {
  746. int status;
  747. struct ocfs2_inode_info *oi1 = OCFS2_I(inode1);
  748. struct ocfs2_inode_info *oi2 = OCFS2_I(inode2);
  749. struct buffer_head **tmpbh;
  750. struct inode *tmpinode;
  751. mlog_entry("(inode1 = %llu, inode2 = %llu)\n",
  752. (unsigned long long)oi1->ip_blkno,
  753. (unsigned long long)oi2->ip_blkno);
  754. if (*bh1)
  755. *bh1 = NULL;
  756. if (*bh2)
  757. *bh2 = NULL;
  758. /* we always want to lock the one with the lower lockid first. */
  759. if (oi1->ip_blkno != oi2->ip_blkno) {
  760. if (oi1->ip_blkno < oi2->ip_blkno) {
  761. /* switch id1 and id2 around */
  762. mlog(0, "switching them around...\n");
  763. tmpbh = bh2;
  764. bh2 = bh1;
  765. bh1 = tmpbh;
  766. tmpinode = inode2;
  767. inode2 = inode1;
  768. inode1 = tmpinode;
  769. }
  770. /* lock id2 */
  771. status = ocfs2_inode_lock(inode2, bh2, 1);
  772. if (status < 0) {
  773. if (status != -ENOENT)
  774. mlog_errno(status);
  775. goto bail;
  776. }
  777. }
  778. /* lock id1 */
  779. status = ocfs2_inode_lock(inode1, bh1, 1);
  780. if (status < 0) {
  781. /*
  782. * An error return must mean that no cluster locks
  783. * were held on function exit.
  784. */
  785. if (oi1->ip_blkno != oi2->ip_blkno)
  786. ocfs2_inode_unlock(inode2, 1);
  787. if (status != -ENOENT)
  788. mlog_errno(status);
  789. }
  790. bail:
  791. mlog_exit(status);
  792. return status;
  793. }
  794. static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2)
  795. {
  796. ocfs2_inode_unlock(inode1, 1);
  797. if (inode1 != inode2)
  798. ocfs2_inode_unlock(inode2, 1);
  799. }
  800. static int ocfs2_rename(struct inode *old_dir,
  801. struct dentry *old_dentry,
  802. struct inode *new_dir,
  803. struct dentry *new_dentry)
  804. {
  805. int status = 0, rename_lock = 0, parents_locked = 0;
  806. int old_child_locked = 0, new_child_locked = 0;
  807. struct inode *old_inode = old_dentry->d_inode;
  808. struct inode *new_inode = new_dentry->d_inode;
  809. struct inode *orphan_dir = NULL;
  810. struct ocfs2_dinode *newfe = NULL;
  811. char orphan_name[OCFS2_ORPHAN_NAMELEN + 1];
  812. struct buffer_head *orphan_entry_bh = NULL;
  813. struct buffer_head *newfe_bh = NULL;
  814. struct buffer_head *old_inode_bh = NULL;
  815. struct buffer_head *insert_entry_bh = NULL;
  816. struct ocfs2_super *osb = NULL;
  817. u64 newfe_blkno, old_de_ino;
  818. handle_t *handle = NULL;
  819. struct buffer_head *old_dir_bh = NULL;
  820. struct buffer_head *new_dir_bh = NULL;
  821. struct ocfs2_dir_entry *old_inode_dot_dot_de = NULL, *old_de = NULL,
  822. *new_de = NULL;
  823. struct buffer_head *new_de_bh = NULL, *old_de_bh = NULL; // bhs for above
  824. struct buffer_head *old_inode_de_bh = NULL; // if old_dentry is a dir,
  825. // this is the 1st dirent bh
  826. nlink_t old_dir_nlink = old_dir->i_nlink;
  827. struct ocfs2_dinode *old_di;
  828. /* At some point it might be nice to break this function up a
  829. * bit. */
  830. mlog_entry("(0x%p, 0x%p, 0x%p, 0x%p, from='%.*s' to='%.*s')\n",
  831. old_dir, old_dentry, new_dir, new_dentry,
  832. old_dentry->d_name.len, old_dentry->d_name.name,
  833. new_dentry->d_name.len, new_dentry->d_name.name);
  834. osb = OCFS2_SB(old_dir->i_sb);
  835. if (new_inode) {
  836. if (!igrab(new_inode))
  837. BUG();
  838. }
  839. /* Assume a directory hierarchy thusly:
  840. * a/b/c
  841. * a/d
  842. * a,b,c, and d are all directories.
  843. *
  844. * from cwd of 'a' on both nodes:
  845. * node1: mv b/c d
  846. * node2: mv d b/c
  847. *
  848. * And that's why, just like the VFS, we need a file system
  849. * rename lock. */
  850. if (old_dir != new_dir && S_ISDIR(old_inode->i_mode)) {
  851. status = ocfs2_rename_lock(osb);
  852. if (status < 0) {
  853. mlog_errno(status);
  854. goto bail;
  855. }
  856. rename_lock = 1;
  857. }
  858. /* if old and new are the same, this'll just do one lock. */
  859. status = ocfs2_double_lock(osb, &old_dir_bh, old_dir,
  860. &new_dir_bh, new_dir);
  861. if (status < 0) {
  862. mlog_errno(status);
  863. goto bail;
  864. }
  865. parents_locked = 1;
  866. /* make sure both dirs have bhs
  867. * get an extra ref on old_dir_bh if old==new */
  868. if (!new_dir_bh) {
  869. if (old_dir_bh) {
  870. new_dir_bh = old_dir_bh;
  871. get_bh(new_dir_bh);
  872. } else {
  873. mlog(ML_ERROR, "no old_dir_bh!\n");
  874. status = -EIO;
  875. goto bail;
  876. }
  877. }
  878. /*
  879. * Aside from allowing a meta data update, the locking here
  880. * also ensures that the downconvert thread on other nodes
  881. * won't have to concurrently downconvert the inode and the
  882. * dentry locks.
  883. */
  884. status = ocfs2_inode_lock(old_inode, &old_inode_bh, 1);
  885. if (status < 0) {
  886. if (status != -ENOENT)
  887. mlog_errno(status);
  888. goto bail;
  889. }
  890. old_child_locked = 1;
  891. status = ocfs2_remote_dentry_delete(old_dentry);
  892. if (status < 0) {
  893. mlog_errno(status);
  894. goto bail;
  895. }
  896. if (S_ISDIR(old_inode->i_mode)) {
  897. u64 old_inode_parent;
  898. status = ocfs2_find_files_on_disk("..", 2, &old_inode_parent,
  899. old_inode, &old_inode_de_bh,
  900. &old_inode_dot_dot_de);
  901. if (status) {
  902. status = -EIO;
  903. goto bail;
  904. }
  905. if (old_inode_parent != OCFS2_I(old_dir)->ip_blkno) {
  906. status = -EIO;
  907. goto bail;
  908. }
  909. if (!new_inode && new_dir != old_dir &&
  910. new_dir->i_nlink >= OCFS2_LINK_MAX) {
  911. status = -EMLINK;
  912. goto bail;
  913. }
  914. }
  915. status = ocfs2_lookup_ino_from_name(old_dir, old_dentry->d_name.name,
  916. old_dentry->d_name.len,
  917. &old_de_ino);
  918. if (status) {
  919. status = -ENOENT;
  920. goto bail;
  921. }
  922. /*
  923. * Check for inode number is _not_ due to possible IO errors.
  924. * We might rmdir the source, keep it as pwd of some process
  925. * and merrily kill the link to whatever was created under the
  926. * same name. Goodbye sticky bit ;-<
  927. */
  928. if (old_de_ino != OCFS2_I(old_inode)->ip_blkno) {
  929. status = -ENOENT;
  930. goto bail;
  931. }
  932. /* check if the target already exists (in which case we need
  933. * to delete it */
  934. status = ocfs2_find_files_on_disk(new_dentry->d_name.name,
  935. new_dentry->d_name.len,
  936. &newfe_blkno, new_dir, &new_de_bh,
  937. &new_de);
  938. /* The only error we allow here is -ENOENT because the new
  939. * file not existing is perfectly valid. */
  940. if ((status < 0) && (status != -ENOENT)) {
  941. /* If we cannot find the file specified we should just */
  942. /* return the error... */
  943. mlog_errno(status);
  944. goto bail;
  945. }
  946. if (!new_de && new_inode) {
  947. /*
  948. * Target was unlinked by another node while we were
  949. * waiting to get to ocfs2_rename(). There isn't
  950. * anything we can do here to help the situation, so
  951. * bubble up the appropriate error.
  952. */
  953. status = -ENOENT;
  954. goto bail;
  955. }
  956. /* In case we need to overwrite an existing file, we blow it
  957. * away first */
  958. if (new_de) {
  959. /* VFS didn't think there existed an inode here, but
  960. * someone else in the cluster must have raced our
  961. * rename to create one. Today we error cleanly, in
  962. * the future we should consider calling iget to build
  963. * a new struct inode for this entry. */
  964. if (!new_inode) {
  965. status = -EACCES;
  966. mlog(0, "We found an inode for name %.*s but VFS "
  967. "didn't give us one.\n", new_dentry->d_name.len,
  968. new_dentry->d_name.name);
  969. goto bail;
  970. }
  971. if (OCFS2_I(new_inode)->ip_blkno != newfe_blkno) {
  972. status = -EACCES;
  973. mlog(0, "Inode %llu and dir %llu disagree. flags = %x\n",
  974. (unsigned long long)OCFS2_I(new_inode)->ip_blkno,
  975. (unsigned long long)newfe_blkno,
  976. OCFS2_I(new_inode)->ip_flags);
  977. goto bail;
  978. }
  979. status = ocfs2_inode_lock(new_inode, &newfe_bh, 1);
  980. if (status < 0) {
  981. if (status != -ENOENT)
  982. mlog_errno(status);
  983. goto bail;
  984. }
  985. new_child_locked = 1;
  986. status = ocfs2_remote_dentry_delete(new_dentry);
  987. if (status < 0) {
  988. mlog_errno(status);
  989. goto bail;
  990. }
  991. newfe = (struct ocfs2_dinode *) newfe_bh->b_data;
  992. mlog(0, "aha rename over existing... new_de=%p new_blkno=%llu "
  993. "newfebh=%p bhblocknr=%llu\n", new_de,
  994. (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ?
  995. (unsigned long long)newfe_bh->b_blocknr : 0ULL);
  996. if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) {
  997. status = ocfs2_prepare_orphan_dir(osb, &orphan_dir,
  998. new_inode,
  999. orphan_name,
  1000. &orphan_entry_bh);
  1001. if (status < 0) {
  1002. mlog_errno(status);
  1003. goto bail;
  1004. }
  1005. }
  1006. } else {
  1007. BUG_ON(new_dentry->d_parent->d_inode != new_dir);
  1008. status = ocfs2_check_dir_for_entry(new_dir,
  1009. new_dentry->d_name.name,
  1010. new_dentry->d_name.len);
  1011. if (status)
  1012. goto bail;
  1013. status = ocfs2_prepare_dir_for_insert(osb, new_dir, new_dir_bh,
  1014. new_dentry->d_name.name,
  1015. new_dentry->d_name.len,
  1016. &insert_entry_bh);
  1017. if (status < 0) {
  1018. mlog_errno(status);
  1019. goto bail;
  1020. }
  1021. }
  1022. handle = ocfs2_start_trans(osb, OCFS2_RENAME_CREDITS);
  1023. if (IS_ERR(handle)) {
  1024. status = PTR_ERR(handle);
  1025. handle = NULL;
  1026. mlog_errno(status);
  1027. goto bail;
  1028. }
  1029. if (new_de) {
  1030. if (S_ISDIR(new_inode->i_mode)) {
  1031. if (!ocfs2_empty_dir(new_inode) ||
  1032. new_inode->i_nlink != 2) {
  1033. status = -ENOTEMPTY;
  1034. goto bail;
  1035. }
  1036. }
  1037. status = ocfs2_journal_access(handle, new_inode, newfe_bh,
  1038. OCFS2_JOURNAL_ACCESS_WRITE);
  1039. if (status < 0) {
  1040. mlog_errno(status);
  1041. goto bail;
  1042. }
  1043. if (S_ISDIR(new_inode->i_mode) ||
  1044. (newfe->i_links_count == cpu_to_le16(1))){
  1045. status = ocfs2_orphan_add(osb, handle, new_inode,
  1046. newfe, orphan_name,
  1047. orphan_entry_bh, orphan_dir);
  1048. if (status < 0) {
  1049. mlog_errno(status);
  1050. goto bail;
  1051. }
  1052. }
  1053. /* change the dirent to point to the correct inode */
  1054. status = ocfs2_update_entry(new_dir, handle, new_de_bh,
  1055. new_de, old_inode);
  1056. if (status < 0) {
  1057. mlog_errno(status);
  1058. goto bail;
  1059. }
  1060. new_dir->i_version++;
  1061. if (S_ISDIR(new_inode->i_mode))
  1062. newfe->i_links_count = 0;
  1063. else
  1064. le16_add_cpu(&newfe->i_links_count, -1);
  1065. status = ocfs2_journal_dirty(handle, newfe_bh);
  1066. if (status < 0) {
  1067. mlog_errno(status);
  1068. goto bail;
  1069. }
  1070. } else {
  1071. /* if the name was not found in new_dir, add it now */
  1072. status = ocfs2_add_entry(handle, new_dentry, old_inode,
  1073. OCFS2_I(old_inode)->ip_blkno,
  1074. new_dir_bh, insert_entry_bh);
  1075. }
  1076. old_inode->i_ctime = CURRENT_TIME;
  1077. mark_inode_dirty(old_inode);
  1078. status = ocfs2_journal_access(handle, old_inode, old_inode_bh,
  1079. OCFS2_JOURNAL_ACCESS_WRITE);
  1080. if (status >= 0) {
  1081. old_di = (struct ocfs2_dinode *) old_inode_bh->b_data;
  1082. old_di->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec);
  1083. old_di->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec);
  1084. status = ocfs2_journal_dirty(handle, old_inode_bh);
  1085. if (status < 0)
  1086. mlog_errno(status);
  1087. } else
  1088. mlog_errno(status);
  1089. /*
  1090. * Now that the name has been added to new_dir, remove the old name.
  1091. *
  1092. * We don't keep any directory entry context around until now
  1093. * because the insert might have changed the type of directory
  1094. * we're dealing with.
  1095. */
  1096. old_de_bh = ocfs2_find_entry(old_dentry->d_name.name,
  1097. old_dentry->d_name.len,
  1098. old_dir, &old_de);
  1099. if (!old_de_bh) {
  1100. status = -EIO;
  1101. goto bail;
  1102. }
  1103. status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh);
  1104. if (status < 0) {
  1105. mlog_errno(status);
  1106. goto bail;
  1107. }
  1108. if (new_inode) {
  1109. new_inode->i_nlink--;
  1110. new_inode->i_ctime = CURRENT_TIME;
  1111. }
  1112. old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
  1113. if (old_inode_de_bh) {
  1114. status = ocfs2_update_entry(old_inode, handle, old_inode_de_bh,
  1115. old_inode_dot_dot_de, new_dir);
  1116. old_dir->i_nlink--;
  1117. if (new_inode) {
  1118. new_inode->i_nlink--;
  1119. } else {
  1120. inc_nlink(new_dir);
  1121. mark_inode_dirty(new_dir);
  1122. }
  1123. }
  1124. mark_inode_dirty(old_dir);
  1125. ocfs2_mark_inode_dirty(handle, old_dir, old_dir_bh);
  1126. if (new_inode) {
  1127. mark_inode_dirty(new_inode);
  1128. ocfs2_mark_inode_dirty(handle, new_inode, newfe_bh);
  1129. }
  1130. if (old_dir != new_dir) {
  1131. /* Keep the same times on both directories.*/
  1132. new_dir->i_ctime = new_dir->i_mtime = old_dir->i_ctime;
  1133. /*
  1134. * This will also pick up the i_nlink change from the
  1135. * block above.
  1136. */
  1137. ocfs2_mark_inode_dirty(handle, new_dir, new_dir_bh);
  1138. }
  1139. if (old_dir_nlink != old_dir->i_nlink) {
  1140. if (!old_dir_bh) {
  1141. mlog(ML_ERROR, "need to change nlink for old dir "
  1142. "%llu from %d to %d but bh is NULL!\n",
  1143. (unsigned long long)OCFS2_I(old_dir)->ip_blkno,
  1144. (int)old_dir_nlink, old_dir->i_nlink);
  1145. } else {
  1146. struct ocfs2_dinode *fe;
  1147. status = ocfs2_journal_access(handle, old_dir,
  1148. old_dir_bh,
  1149. OCFS2_JOURNAL_ACCESS_WRITE);
  1150. fe = (struct ocfs2_dinode *) old_dir_bh->b_data;
  1151. fe->i_links_count = cpu_to_le16(old_dir->i_nlink);
  1152. status = ocfs2_journal_dirty(handle, old_dir_bh);
  1153. }
  1154. }
  1155. ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir);
  1156. status = 0;
  1157. bail:
  1158. if (rename_lock)
  1159. ocfs2_rename_unlock(osb);
  1160. if (handle)
  1161. ocfs2_commit_trans(osb, handle);
  1162. if (parents_locked)
  1163. ocfs2_double_unlock(old_dir, new_dir);
  1164. if (old_child_locked)
  1165. ocfs2_inode_unlock(old_inode, 1);
  1166. if (new_child_locked)
  1167. ocfs2_inode_unlock(new_inode, 1);
  1168. if (orphan_dir) {
  1169. /* This was locked for us in ocfs2_prepare_orphan_dir() */
  1170. ocfs2_inode_unlock(orphan_dir, 1);
  1171. mutex_unlock(&orphan_dir->i_mutex);
  1172. iput(orphan_dir);
  1173. }
  1174. if (new_inode)
  1175. sync_mapping_buffers(old_inode->i_mapping);
  1176. if (new_inode)
  1177. iput(new_inode);
  1178. brelse(newfe_bh);
  1179. brelse(old_inode_bh);
  1180. brelse(old_dir_bh);
  1181. brelse(new_dir_bh);
  1182. brelse(new_de_bh);
  1183. brelse(old_de_bh);
  1184. brelse(old_inode_de_bh);
  1185. brelse(orphan_entry_bh);
  1186. brelse(insert_entry_bh);
  1187. mlog_exit(status);
  1188. return status;
  1189. }
  1190. /*
  1191. * we expect i_size = strlen(symname). Copy symname into the file
  1192. * data, including the null terminator.
  1193. */
  1194. static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
  1195. handle_t *handle,
  1196. struct inode *inode,
  1197. const char *symname)
  1198. {
  1199. struct buffer_head **bhs = NULL;
  1200. const char *c;
  1201. struct super_block *sb = osb->sb;
  1202. u64 p_blkno, p_blocks;
  1203. int virtual, blocks, status, i, bytes_left;
  1204. bytes_left = i_size_read(inode) + 1;
  1205. /* we can't trust i_blocks because we're actually going to
  1206. * write i_size + 1 bytes. */
  1207. blocks = (bytes_left + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
  1208. mlog_entry("i_blocks = %llu, i_size = %llu, blocks = %d\n",
  1209. (unsigned long long)inode->i_blocks,
  1210. i_size_read(inode), blocks);
  1211. /* Sanity check -- make sure we're going to fit. */
  1212. if (bytes_left >
  1213. ocfs2_clusters_to_bytes(sb, OCFS2_I(inode)->ip_clusters)) {
  1214. status = -EIO;
  1215. mlog_errno(status);
  1216. goto bail;
  1217. }
  1218. bhs = kcalloc(blocks, sizeof(struct buffer_head *), GFP_KERNEL);
  1219. if (!bhs) {
  1220. status = -ENOMEM;
  1221. mlog_errno(status);
  1222. goto bail;
  1223. }
  1224. status = ocfs2_extent_map_get_blocks(inode, 0, &p_blkno, &p_blocks,
  1225. NULL);
  1226. if (status < 0) {
  1227. mlog_errno(status);
  1228. goto bail;
  1229. }
  1230. /* links can never be larger than one cluster so we know this
  1231. * is all going to be contiguous, but do a sanity check
  1232. * anyway. */
  1233. if ((p_blocks << sb->s_blocksize_bits) < bytes_left) {
  1234. status = -EIO;
  1235. mlog_errno(status);
  1236. goto bail;
  1237. }
  1238. virtual = 0;
  1239. while(bytes_left > 0) {
  1240. c = &symname[virtual * sb->s_blocksize];
  1241. bhs[virtual] = sb_getblk(sb, p_blkno);
  1242. if (!bhs[virtual]) {
  1243. status = -ENOMEM;
  1244. mlog_errno(status);
  1245. goto bail;
  1246. }
  1247. ocfs2_set_new_buffer_uptodate(inode, bhs[virtual]);
  1248. status = ocfs2_journal_access(handle, inode, bhs[virtual],
  1249. OCFS2_JOURNAL_ACCESS_CREATE);
  1250. if (status < 0) {
  1251. mlog_errno(status);
  1252. goto bail;
  1253. }
  1254. memset(bhs[virtual]->b_data, 0, sb->s_blocksize);
  1255. memcpy(bhs[virtual]->b_data, c,
  1256. (bytes_left > sb->s_blocksize) ? sb->s_blocksize :
  1257. bytes_left);
  1258. status = ocfs2_journal_dirty(handle, bhs[virtual]);
  1259. if (status < 0) {
  1260. mlog_errno(status);
  1261. goto bail;
  1262. }
  1263. virtual++;
  1264. p_blkno++;
  1265. bytes_left -= sb->s_blocksize;
  1266. }
  1267. status = 0;
  1268. bail:
  1269. if (bhs) {
  1270. for(i = 0; i < blocks; i++)
  1271. brelse(bhs[i]);
  1272. kfree(bhs);
  1273. }
  1274. mlog_exit(status);
  1275. return status;
  1276. }
  1277. static int ocfs2_symlink(struct inode *dir,
  1278. struct dentry *dentry,
  1279. const char *symname)
  1280. {
  1281. int status, l, credits;
  1282. u64 newsize;
  1283. struct ocfs2_super *osb = NULL;
  1284. struct inode *inode = NULL;
  1285. struct super_block *sb;
  1286. struct buffer_head *new_fe_bh = NULL;
  1287. struct buffer_head *de_bh = NULL;
  1288. struct buffer_head *parent_fe_bh = NULL;
  1289. struct ocfs2_dinode *fe = NULL;
  1290. struct ocfs2_dinode *dirfe;
  1291. handle_t *handle = NULL;
  1292. struct ocfs2_alloc_context *inode_ac = NULL;
  1293. struct ocfs2_alloc_context *data_ac = NULL;
  1294. mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir,
  1295. dentry, symname, dentry->d_name.len, dentry->d_name.name);
  1296. sb = dir->i_sb;
  1297. osb = OCFS2_SB(sb);
  1298. l = strlen(symname) + 1;
  1299. credits = ocfs2_calc_symlink_credits(sb);
  1300. /* lock the parent directory */
  1301. status = ocfs2_inode_lock(dir, &parent_fe_bh, 1);
  1302. if (status < 0) {
  1303. if (status != -ENOENT)
  1304. mlog_errno(status);
  1305. return status;
  1306. }
  1307. dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data;
  1308. if (!dirfe->i_links_count) {
  1309. /* can't make a file in a deleted directory. */
  1310. status = -ENOENT;
  1311. goto bail;
  1312. }
  1313. status = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
  1314. dentry->d_name.len);
  1315. if (status)
  1316. goto bail;
  1317. status = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
  1318. dentry->d_name.name,
  1319. dentry->d_name.len, &de_bh);
  1320. if (status < 0) {
  1321. mlog_errno(status);
  1322. goto bail;
  1323. }
  1324. status = ocfs2_reserve_new_inode(osb, &inode_ac);
  1325. if (status < 0) {
  1326. if (status != -ENOSPC)
  1327. mlog_errno(status);
  1328. goto bail;
  1329. }
  1330. inode = ocfs2_get_init_inode(dir, S_IFLNK | S_IRWXUGO);
  1331. if (!inode) {
  1332. status = -ENOMEM;
  1333. mlog_errno(status);
  1334. goto bail;
  1335. }
  1336. /* don't reserve bitmap space for fast symlinks. */
  1337. if (l > ocfs2_fast_symlink_chars(sb)) {
  1338. status = ocfs2_reserve_clusters(osb, 1, &data_ac);
  1339. if (status < 0) {
  1340. if (status != -ENOSPC)
  1341. mlog_errno(status);
  1342. goto bail;
  1343. }
  1344. }
  1345. handle = ocfs2_start_trans(osb, credits);
  1346. if (IS_ERR(handle)) {
  1347. status = PTR_ERR(handle);
  1348. handle = NULL;
  1349. mlog_errno(status);
  1350. goto bail;
  1351. }
  1352. status = ocfs2_mknod_locked(osb, dir, inode, dentry,
  1353. 0, &new_fe_bh, parent_fe_bh, handle,
  1354. inode_ac);
  1355. if (status < 0) {
  1356. mlog_errno(status);
  1357. goto bail;
  1358. }
  1359. fe = (struct ocfs2_dinode *) new_fe_bh->b_data;
  1360. inode->i_rdev = 0;
  1361. newsize = l - 1;
  1362. if (l > ocfs2_fast_symlink_chars(sb)) {
  1363. u32 offset = 0;
  1364. inode->i_op = &ocfs2_symlink_inode_operations;
  1365. status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0,
  1366. new_fe_bh,
  1367. handle, data_ac, NULL,
  1368. NULL);
  1369. if (status < 0) {
  1370. if (status != -ENOSPC && status != -EINTR) {
  1371. mlog(ML_ERROR,
  1372. "Failed to extend file to %llu\n",
  1373. (unsigned long long)newsize);
  1374. mlog_errno(status);
  1375. status = -ENOSPC;
  1376. }
  1377. goto bail;
  1378. }
  1379. i_size_write(inode, newsize);
  1380. inode->i_blocks = ocfs2_inode_sector_count(inode);
  1381. } else {
  1382. inode->i_op = &ocfs2_fast_symlink_inode_operations;
  1383. memcpy((char *) fe->id2.i_symlink, symname, l);
  1384. i_size_write(inode, newsize);
  1385. inode->i_blocks = 0;
  1386. }
  1387. status = ocfs2_mark_inode_dirty(handle, inode, new_fe_bh);
  1388. if (status < 0) {
  1389. mlog_errno(status);
  1390. goto bail;
  1391. }
  1392. if (!ocfs2_inode_is_fast_symlink(inode)) {
  1393. status = ocfs2_create_symlink_data(osb, handle, inode,
  1394. symname);
  1395. if (status < 0) {
  1396. mlog_errno(status);
  1397. goto bail;
  1398. }
  1399. }
  1400. status = ocfs2_add_entry(handle, dentry, inode,
  1401. le64_to_cpu(fe->i_blkno), parent_fe_bh,
  1402. de_bh);
  1403. if (status < 0) {
  1404. mlog_errno(status);
  1405. goto bail;
  1406. }
  1407. status = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
  1408. if (status) {
  1409. mlog_errno(status);
  1410. goto bail;
  1411. }
  1412. insert_inode_hash(inode);
  1413. dentry->d_op = &ocfs2_dentry_ops;
  1414. d_instantiate(dentry, inode);
  1415. bail:
  1416. if (handle)
  1417. ocfs2_commit_trans(osb, handle);
  1418. ocfs2_inode_unlock(dir, 1);
  1419. brelse(new_fe_bh);
  1420. brelse(parent_fe_bh);
  1421. brelse(de_bh);
  1422. if (inode_ac)
  1423. ocfs2_free_alloc_context(inode_ac);
  1424. if (data_ac)
  1425. ocfs2_free_alloc_context(data_ac);
  1426. if ((status < 0) && inode) {
  1427. clear_nlink(inode);
  1428. iput(inode);
  1429. }
  1430. mlog_exit(status);
  1431. return status;
  1432. }
  1433. static int ocfs2_blkno_stringify(u64 blkno, char *name)
  1434. {
  1435. int status, namelen;
  1436. mlog_entry_void();
  1437. namelen = snprintf(name, OCFS2_ORPHAN_NAMELEN + 1, "%016llx",
  1438. (long long)blkno);
  1439. if (namelen <= 0) {
  1440. if (namelen)
  1441. status = namelen;
  1442. else
  1443. status = -EINVAL;
  1444. mlog_errno(status);
  1445. goto bail;
  1446. }
  1447. if (namelen != OCFS2_ORPHAN_NAMELEN) {
  1448. status = -EINVAL;
  1449. mlog_errno(status);
  1450. goto bail;
  1451. }
  1452. mlog(0, "built filename '%s' for orphan dir (len=%d)\n", name,
  1453. namelen);
  1454. status = 0;
  1455. bail:
  1456. mlog_exit(status);
  1457. return status;
  1458. }
  1459. static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
  1460. struct inode **ret_orphan_dir,
  1461. struct inode *inode,
  1462. char *name,
  1463. struct buffer_head **de_bh)
  1464. {
  1465. struct inode *orphan_dir_inode;
  1466. struct buffer_head *orphan_dir_bh = NULL;
  1467. int status = 0;
  1468. status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name);
  1469. if (status < 0) {
  1470. mlog_errno(status);
  1471. return status;
  1472. }
  1473. orphan_dir_inode = ocfs2_get_system_file_inode(osb,
  1474. ORPHAN_DIR_SYSTEM_INODE,
  1475. osb->slot_num);
  1476. if (!orphan_dir_inode) {
  1477. status = -ENOENT;
  1478. mlog_errno(status);
  1479. return status;
  1480. }
  1481. mutex_lock(&orphan_dir_inode->i_mutex);
  1482. status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
  1483. if (status < 0) {
  1484. mlog_errno(status);
  1485. goto leave;
  1486. }
  1487. status = ocfs2_prepare_dir_for_insert(osb, orphan_dir_inode,
  1488. orphan_dir_bh, name,
  1489. OCFS2_ORPHAN_NAMELEN, de_bh);
  1490. if (status < 0) {
  1491. ocfs2_inode_unlock(orphan_dir_inode, 1);
  1492. mlog_errno(status);
  1493. goto leave;
  1494. }
  1495. *ret_orphan_dir = orphan_dir_inode;
  1496. leave:
  1497. if (status) {
  1498. mutex_unlock(&orphan_dir_inode->i_mutex);
  1499. iput(orphan_dir_inode);
  1500. }
  1501. brelse(orphan_dir_bh);
  1502. mlog_exit(status);
  1503. return status;
  1504. }
  1505. static int ocfs2_orphan_add(struct ocfs2_super *osb,
  1506. handle_t *handle,
  1507. struct inode *inode,
  1508. struct ocfs2_dinode *fe,
  1509. char *name,
  1510. struct buffer_head *de_bh,
  1511. struct inode *orphan_dir_inode)
  1512. {
  1513. struct buffer_head *orphan_dir_bh = NULL;
  1514. int status = 0;
  1515. struct ocfs2_dinode *orphan_fe;
  1516. mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino);
  1517. status = ocfs2_read_block(orphan_dir_inode,
  1518. OCFS2_I(orphan_dir_inode)->ip_blkno,
  1519. &orphan_dir_bh);
  1520. if (status < 0) {
  1521. mlog_errno(status);
  1522. goto leave;
  1523. }
  1524. status = ocfs2_journal_access(handle, orphan_dir_inode, orphan_dir_bh,
  1525. OCFS2_JOURNAL_ACCESS_WRITE);
  1526. if (status < 0) {
  1527. mlog_errno(status);
  1528. goto leave;
  1529. }
  1530. /* we're a cluster, and nlink can change on disk from
  1531. * underneath us... */
  1532. orphan_fe = (struct ocfs2_dinode *) orphan_dir_bh->b_data;
  1533. if (S_ISDIR(inode->i_mode))
  1534. le16_add_cpu(&orphan_fe->i_links_count, 1);
  1535. orphan_dir_inode->i_nlink = le16_to_cpu(orphan_fe->i_links_count);
  1536. status = ocfs2_journal_dirty(handle, orphan_dir_bh);
  1537. if (status < 0) {
  1538. mlog_errno(status);
  1539. goto leave;
  1540. }
  1541. status = __ocfs2_add_entry(handle, orphan_dir_inode, name,
  1542. OCFS2_ORPHAN_NAMELEN, inode,
  1543. OCFS2_I(inode)->ip_blkno,
  1544. orphan_dir_bh, de_bh);
  1545. if (status < 0) {
  1546. mlog_errno(status);
  1547. goto leave;
  1548. }
  1549. le32_add_cpu(&fe->i_flags, OCFS2_ORPHANED_FL);
  1550. /* Record which orphan dir our inode now resides
  1551. * in. delete_inode will use this to determine which orphan
  1552. * dir to lock. */
  1553. fe->i_orphaned_slot = cpu_to_le16(osb->slot_num);
  1554. mlog(0, "Inode %llu orphaned in slot %d\n",
  1555. (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num);
  1556. leave:
  1557. brelse(orphan_dir_bh);
  1558. mlog_exit(status);
  1559. return status;
  1560. }
  1561. /* unlike orphan_add, we expect the orphan dir to already be locked here. */
  1562. int ocfs2_orphan_del(struct ocfs2_super *osb,
  1563. handle_t *handle,
  1564. struct inode *orphan_dir_inode,
  1565. struct inode *inode,
  1566. struct buffer_head *orphan_dir_bh)
  1567. {
  1568. char name[OCFS2_ORPHAN_NAMELEN + 1];
  1569. struct ocfs2_dinode *orphan_fe;
  1570. int status = 0;
  1571. struct buffer_head *target_de_bh = NULL;
  1572. struct ocfs2_dir_entry *target_de = NULL;
  1573. mlog_entry_void();
  1574. status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name);
  1575. if (status < 0) {
  1576. mlog_errno(status);
  1577. goto leave;
  1578. }
  1579. mlog(0, "removing '%s' from orphan dir %llu (namelen=%d)\n",
  1580. name, (unsigned long long)OCFS2_I(orphan_dir_inode)->ip_blkno,
  1581. OCFS2_ORPHAN_NAMELEN);
  1582. /* find it's spot in the orphan directory */
  1583. target_de_bh = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN,
  1584. orphan_dir_inode, &target_de);
  1585. if (!target_de_bh) {
  1586. status = -ENOENT;
  1587. mlog_errno(status);
  1588. goto leave;
  1589. }
  1590. /* remove it from the orphan directory */
  1591. status = ocfs2_delete_entry(handle, orphan_dir_inode, target_de,
  1592. target_de_bh);
  1593. if (status < 0) {
  1594. mlog_errno(status);
  1595. goto leave;
  1596. }
  1597. status = ocfs2_journal_access(handle,orphan_dir_inode, orphan_dir_bh,
  1598. OCFS2_JOURNAL_ACCESS_WRITE);
  1599. if (status < 0) {
  1600. mlog_errno(status);
  1601. goto leave;
  1602. }
  1603. /* do the i_nlink dance! :) */
  1604. orphan_fe = (struct ocfs2_dinode *) orphan_dir_bh->b_data;
  1605. if (S_ISDIR(inode->i_mode))
  1606. le16_add_cpu(&orphan_fe->i_links_count, -1);
  1607. orphan_dir_inode->i_nlink = le16_to_cpu(orphan_fe->i_links_count);
  1608. status = ocfs2_journal_dirty(handle, orphan_dir_bh);
  1609. if (status < 0) {
  1610. mlog_errno(status);
  1611. goto leave;
  1612. }
  1613. leave:
  1614. brelse(target_de_bh);
  1615. mlog_exit(status);
  1616. return status;
  1617. }
  1618. const struct inode_operations ocfs2_dir_iops = {
  1619. .create = ocfs2_create,
  1620. .lookup = ocfs2_lookup,
  1621. .link = ocfs2_link,
  1622. .unlink = ocfs2_unlink,
  1623. .rmdir = ocfs2_unlink,
  1624. .symlink = ocfs2_symlink,
  1625. .mkdir = ocfs2_mkdir,
  1626. .mknod = ocfs2_mknod,
  1627. .rename = ocfs2_rename,
  1628. .setattr = ocfs2_setattr,
  1629. .getattr = ocfs2_getattr,
  1630. .permission = ocfs2_permission,
  1631. .setxattr = generic_setxattr,
  1632. .getxattr = generic_getxattr,
  1633. .listxattr = ocfs2_listxattr,
  1634. .removexattr = generic_removexattr,
  1635. };