xfs_iops.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "xfs.h"
  19. #include "xfs_fs.h"
  20. #include "xfs_shared.h"
  21. #include "xfs_format.h"
  22. #include "xfs_log_format.h"
  23. #include "xfs_trans_resv.h"
  24. #include "xfs_mount.h"
  25. #include "xfs_da_format.h"
  26. #include "xfs_inode.h"
  27. #include "xfs_bmap.h"
  28. #include "xfs_bmap_util.h"
  29. #include "xfs_acl.h"
  30. #include "xfs_quota.h"
  31. #include "xfs_error.h"
  32. #include "xfs_attr.h"
  33. #include "xfs_trans.h"
  34. #include "xfs_trace.h"
  35. #include "xfs_icache.h"
  36. #include "xfs_symlink.h"
  37. #include "xfs_da_btree.h"
  38. #include "xfs_dir2.h"
  39. #include "xfs_trans_space.h"
  40. #include "xfs_pnfs.h"
  41. #include "xfs_iomap.h"
  42. #include <linux/capability.h>
  43. #include <linux/xattr.h>
  44. #include <linux/posix_acl.h>
  45. #include <linux/security.h>
  46. #include <linux/iomap.h>
  47. #include <linux/slab.h>
  48. /*
  49. * Directories have different lock order w.r.t. mmap_sem compared to regular
  50. * files. This is due to readdir potentially triggering page faults on a user
  51. * buffer inside filldir(), and this happens with the ilock on the directory
  52. * held. For regular files, the lock order is the other way around - the
  53. * mmap_sem is taken during the page fault, and then we lock the ilock to do
  54. * block mapping. Hence we need a different class for the directory ilock so
  55. * that lockdep can tell them apart.
  56. */
  57. static struct lock_class_key xfs_nondir_ilock_class;
  58. static struct lock_class_key xfs_dir_ilock_class;
  59. static int
  60. xfs_initxattrs(
  61. struct inode *inode,
  62. const struct xattr *xattr_array,
  63. void *fs_info)
  64. {
  65. const struct xattr *xattr;
  66. struct xfs_inode *ip = XFS_I(inode);
  67. int error = 0;
  68. for (xattr = xattr_array; xattr->name != NULL; xattr++) {
  69. error = xfs_attr_set(ip, xattr->name, xattr->value,
  70. xattr->value_len, ATTR_SECURE);
  71. if (error < 0)
  72. break;
  73. }
  74. return error;
  75. }
  76. /*
  77. * Hook in SELinux. This is not quite correct yet, what we really need
  78. * here (as we do for default ACLs) is a mechanism by which creation of
  79. * these attrs can be journalled at inode creation time (along with the
  80. * inode, of course, such that log replay can't cause these to be lost).
  81. */
  82. STATIC int
  83. xfs_init_security(
  84. struct inode *inode,
  85. struct inode *dir,
  86. const struct qstr *qstr)
  87. {
  88. return security_inode_init_security(inode, dir, qstr,
  89. &xfs_initxattrs, NULL);
  90. }
  91. static void
  92. xfs_dentry_to_name(
  93. struct xfs_name *namep,
  94. struct dentry *dentry,
  95. int mode)
  96. {
  97. namep->name = dentry->d_name.name;
  98. namep->len = dentry->d_name.len;
  99. namep->type = xfs_mode_to_ftype[(mode & S_IFMT) >> S_SHIFT];
  100. }
  101. STATIC void
  102. xfs_cleanup_inode(
  103. struct inode *dir,
  104. struct inode *inode,
  105. struct dentry *dentry)
  106. {
  107. struct xfs_name teardown;
  108. /* Oh, the horror.
  109. * If we can't add the ACL or we fail in
  110. * xfs_init_security we must back out.
  111. * ENOSPC can hit here, among other things.
  112. */
  113. xfs_dentry_to_name(&teardown, dentry, 0);
  114. xfs_remove(XFS_I(dir), &teardown, XFS_I(inode));
  115. }
  116. STATIC int
  117. xfs_generic_create(
  118. struct inode *dir,
  119. struct dentry *dentry,
  120. umode_t mode,
  121. dev_t rdev,
  122. bool tmpfile) /* unnamed file */
  123. {
  124. struct inode *inode;
  125. struct xfs_inode *ip = NULL;
  126. struct posix_acl *default_acl, *acl;
  127. struct xfs_name name;
  128. int error;
  129. /*
  130. * Irix uses Missed'em'V split, but doesn't want to see
  131. * the upper 5 bits of (14bit) major.
  132. */
  133. if (S_ISCHR(mode) || S_ISBLK(mode)) {
  134. if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
  135. return -EINVAL;
  136. rdev = sysv_encode_dev(rdev);
  137. } else {
  138. rdev = 0;
  139. }
  140. error = posix_acl_create(dir, &mode, &default_acl, &acl);
  141. if (error)
  142. return error;
  143. if (!tmpfile) {
  144. xfs_dentry_to_name(&name, dentry, mode);
  145. error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip);
  146. } else {
  147. error = xfs_create_tmpfile(XFS_I(dir), dentry, mode, &ip);
  148. }
  149. if (unlikely(error))
  150. goto out_free_acl;
  151. inode = VFS_I(ip);
  152. error = xfs_init_security(inode, dir, &dentry->d_name);
  153. if (unlikely(error))
  154. goto out_cleanup_inode;
  155. #ifdef CONFIG_XFS_POSIX_ACL
  156. if (default_acl) {
  157. error = xfs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
  158. if (error)
  159. goto out_cleanup_inode;
  160. }
  161. if (acl) {
  162. error = xfs_set_acl(inode, acl, ACL_TYPE_ACCESS);
  163. if (error)
  164. goto out_cleanup_inode;
  165. }
  166. #endif
  167. xfs_setup_iops(ip);
  168. if (tmpfile)
  169. d_tmpfile(dentry, inode);
  170. else
  171. d_instantiate(dentry, inode);
  172. xfs_finish_inode_setup(ip);
  173. out_free_acl:
  174. if (default_acl)
  175. posix_acl_release(default_acl);
  176. if (acl)
  177. posix_acl_release(acl);
  178. return error;
  179. out_cleanup_inode:
  180. xfs_finish_inode_setup(ip);
  181. if (!tmpfile)
  182. xfs_cleanup_inode(dir, inode, dentry);
  183. iput(inode);
  184. goto out_free_acl;
  185. }
  186. STATIC int
  187. xfs_vn_mknod(
  188. struct inode *dir,
  189. struct dentry *dentry,
  190. umode_t mode,
  191. dev_t rdev)
  192. {
  193. return xfs_generic_create(dir, dentry, mode, rdev, false);
  194. }
  195. STATIC int
  196. xfs_vn_create(
  197. struct inode *dir,
  198. struct dentry *dentry,
  199. umode_t mode,
  200. bool flags)
  201. {
  202. return xfs_vn_mknod(dir, dentry, mode, 0);
  203. }
  204. STATIC int
  205. xfs_vn_mkdir(
  206. struct inode *dir,
  207. struct dentry *dentry,
  208. umode_t mode)
  209. {
  210. return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0);
  211. }
  212. STATIC struct dentry *
  213. xfs_vn_lookup(
  214. struct inode *dir,
  215. struct dentry *dentry,
  216. unsigned int flags)
  217. {
  218. struct xfs_inode *cip;
  219. struct xfs_name name;
  220. int error;
  221. if (dentry->d_name.len >= MAXNAMELEN)
  222. return ERR_PTR(-ENAMETOOLONG);
  223. xfs_dentry_to_name(&name, dentry, 0);
  224. error = xfs_lookup(XFS_I(dir), &name, &cip, NULL);
  225. if (unlikely(error)) {
  226. if (unlikely(error != -ENOENT))
  227. return ERR_PTR(error);
  228. d_add(dentry, NULL);
  229. return NULL;
  230. }
  231. return d_splice_alias(VFS_I(cip), dentry);
  232. }
  233. STATIC struct dentry *
  234. xfs_vn_ci_lookup(
  235. struct inode *dir,
  236. struct dentry *dentry,
  237. unsigned int flags)
  238. {
  239. struct xfs_inode *ip;
  240. struct xfs_name xname;
  241. struct xfs_name ci_name;
  242. struct qstr dname;
  243. int error;
  244. if (dentry->d_name.len >= MAXNAMELEN)
  245. return ERR_PTR(-ENAMETOOLONG);
  246. xfs_dentry_to_name(&xname, dentry, 0);
  247. error = xfs_lookup(XFS_I(dir), &xname, &ip, &ci_name);
  248. if (unlikely(error)) {
  249. if (unlikely(error != -ENOENT))
  250. return ERR_PTR(error);
  251. /*
  252. * call d_add(dentry, NULL) here when d_drop_negative_children
  253. * is called in xfs_vn_mknod (ie. allow negative dentries
  254. * with CI filesystems).
  255. */
  256. return NULL;
  257. }
  258. /* if exact match, just splice and exit */
  259. if (!ci_name.name)
  260. return d_splice_alias(VFS_I(ip), dentry);
  261. /* else case-insensitive match... */
  262. dname.name = ci_name.name;
  263. dname.len = ci_name.len;
  264. dentry = d_add_ci(dentry, VFS_I(ip), &dname);
  265. kmem_free(ci_name.name);
  266. return dentry;
  267. }
  268. STATIC int
  269. xfs_vn_link(
  270. struct dentry *old_dentry,
  271. struct inode *dir,
  272. struct dentry *dentry)
  273. {
  274. struct inode *inode = d_inode(old_dentry);
  275. struct xfs_name name;
  276. int error;
  277. xfs_dentry_to_name(&name, dentry, inode->i_mode);
  278. error = xfs_link(XFS_I(dir), XFS_I(inode), &name);
  279. if (unlikely(error))
  280. return error;
  281. ihold(inode);
  282. d_instantiate(dentry, inode);
  283. return 0;
  284. }
  285. STATIC int
  286. xfs_vn_unlink(
  287. struct inode *dir,
  288. struct dentry *dentry)
  289. {
  290. struct xfs_name name;
  291. int error;
  292. xfs_dentry_to_name(&name, dentry, 0);
  293. error = xfs_remove(XFS_I(dir), &name, XFS_I(d_inode(dentry)));
  294. if (error)
  295. return error;
  296. /*
  297. * With unlink, the VFS makes the dentry "negative": no inode,
  298. * but still hashed. This is incompatible with case-insensitive
  299. * mode, so invalidate (unhash) the dentry in CI-mode.
  300. */
  301. if (xfs_sb_version_hasasciici(&XFS_M(dir->i_sb)->m_sb))
  302. d_invalidate(dentry);
  303. return 0;
  304. }
  305. STATIC int
  306. xfs_vn_symlink(
  307. struct inode *dir,
  308. struct dentry *dentry,
  309. const char *symname)
  310. {
  311. struct inode *inode;
  312. struct xfs_inode *cip = NULL;
  313. struct xfs_name name;
  314. int error;
  315. umode_t mode;
  316. mode = S_IFLNK |
  317. (irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO);
  318. xfs_dentry_to_name(&name, dentry, mode);
  319. error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip);
  320. if (unlikely(error))
  321. goto out;
  322. inode = VFS_I(cip);
  323. error = xfs_init_security(inode, dir, &dentry->d_name);
  324. if (unlikely(error))
  325. goto out_cleanup_inode;
  326. xfs_setup_iops(cip);
  327. d_instantiate(dentry, inode);
  328. xfs_finish_inode_setup(cip);
  329. return 0;
  330. out_cleanup_inode:
  331. xfs_finish_inode_setup(cip);
  332. xfs_cleanup_inode(dir, inode, dentry);
  333. iput(inode);
  334. out:
  335. return error;
  336. }
  337. STATIC int
  338. xfs_vn_rename(
  339. struct inode *odir,
  340. struct dentry *odentry,
  341. struct inode *ndir,
  342. struct dentry *ndentry,
  343. unsigned int flags)
  344. {
  345. struct inode *new_inode = d_inode(ndentry);
  346. int omode = 0;
  347. struct xfs_name oname;
  348. struct xfs_name nname;
  349. if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
  350. return -EINVAL;
  351. /* if we are exchanging files, we need to set i_mode of both files */
  352. if (flags & RENAME_EXCHANGE)
  353. omode = d_inode(ndentry)->i_mode;
  354. xfs_dentry_to_name(&oname, odentry, omode);
  355. xfs_dentry_to_name(&nname, ndentry, d_inode(odentry)->i_mode);
  356. return xfs_rename(XFS_I(odir), &oname, XFS_I(d_inode(odentry)),
  357. XFS_I(ndir), &nname,
  358. new_inode ? XFS_I(new_inode) : NULL, flags);
  359. }
  360. /*
  361. * careful here - this function can get called recursively, so
  362. * we need to be very careful about how much stack we use.
  363. * uio is kmalloced for this reason...
  364. */
  365. STATIC const char *
  366. xfs_vn_get_link(
  367. struct dentry *dentry,
  368. struct inode *inode,
  369. struct delayed_call *done)
  370. {
  371. char *link;
  372. int error = -ENOMEM;
  373. if (!dentry)
  374. return ERR_PTR(-ECHILD);
  375. link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
  376. if (!link)
  377. goto out_err;
  378. error = xfs_readlink(XFS_I(d_inode(dentry)), link);
  379. if (unlikely(error))
  380. goto out_kfree;
  381. set_delayed_call(done, kfree_link, link);
  382. return link;
  383. out_kfree:
  384. kfree(link);
  385. out_err:
  386. return ERR_PTR(error);
  387. }
  388. STATIC const char *
  389. xfs_vn_get_link_inline(
  390. struct dentry *dentry,
  391. struct inode *inode,
  392. struct delayed_call *done)
  393. {
  394. ASSERT(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE);
  395. return XFS_I(inode)->i_df.if_u1.if_data;
  396. }
  397. STATIC int
  398. xfs_vn_getattr(
  399. struct vfsmount *mnt,
  400. struct dentry *dentry,
  401. struct kstat *stat)
  402. {
  403. struct inode *inode = d_inode(dentry);
  404. struct xfs_inode *ip = XFS_I(inode);
  405. struct xfs_mount *mp = ip->i_mount;
  406. trace_xfs_getattr(ip);
  407. if (XFS_FORCED_SHUTDOWN(mp))
  408. return -EIO;
  409. stat->size = XFS_ISIZE(ip);
  410. stat->dev = inode->i_sb->s_dev;
  411. stat->mode = inode->i_mode;
  412. stat->nlink = inode->i_nlink;
  413. stat->uid = inode->i_uid;
  414. stat->gid = inode->i_gid;
  415. stat->ino = ip->i_ino;
  416. stat->atime = inode->i_atime;
  417. stat->mtime = inode->i_mtime;
  418. stat->ctime = inode->i_ctime;
  419. stat->blocks =
  420. XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
  421. switch (inode->i_mode & S_IFMT) {
  422. case S_IFBLK:
  423. case S_IFCHR:
  424. stat->blksize = BLKDEV_IOSIZE;
  425. stat->rdev = MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
  426. sysv_minor(ip->i_df.if_u2.if_rdev));
  427. break;
  428. default:
  429. if (XFS_IS_REALTIME_INODE(ip)) {
  430. /*
  431. * If the file blocks are being allocated from a
  432. * realtime volume, then return the inode's realtime
  433. * extent size or the realtime volume's extent size.
  434. */
  435. stat->blksize =
  436. xfs_get_extsz_hint(ip) << mp->m_sb.sb_blocklog;
  437. } else
  438. stat->blksize = xfs_preferred_iosize(mp);
  439. stat->rdev = 0;
  440. break;
  441. }
  442. return 0;
  443. }
  444. static void
  445. xfs_setattr_mode(
  446. struct xfs_inode *ip,
  447. struct iattr *iattr)
  448. {
  449. struct inode *inode = VFS_I(ip);
  450. umode_t mode = iattr->ia_mode;
  451. ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
  452. inode->i_mode &= S_IFMT;
  453. inode->i_mode |= mode & ~S_IFMT;
  454. }
  455. void
  456. xfs_setattr_time(
  457. struct xfs_inode *ip,
  458. struct iattr *iattr)
  459. {
  460. struct inode *inode = VFS_I(ip);
  461. ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
  462. if (iattr->ia_valid & ATTR_ATIME)
  463. inode->i_atime = iattr->ia_atime;
  464. if (iattr->ia_valid & ATTR_CTIME)
  465. inode->i_ctime = iattr->ia_ctime;
  466. if (iattr->ia_valid & ATTR_MTIME)
  467. inode->i_mtime = iattr->ia_mtime;
  468. }
  469. static int
  470. xfs_vn_change_ok(
  471. struct dentry *dentry,
  472. struct iattr *iattr)
  473. {
  474. struct xfs_mount *mp = XFS_I(d_inode(dentry))->i_mount;
  475. if (mp->m_flags & XFS_MOUNT_RDONLY)
  476. return -EROFS;
  477. if (XFS_FORCED_SHUTDOWN(mp))
  478. return -EIO;
  479. return setattr_prepare(dentry, iattr);
  480. }
  481. /*
  482. * Set non-size attributes of an inode.
  483. *
  484. * Caution: The caller of this function is responsible for calling
  485. * setattr_prepare() or otherwise verifying the change is fine.
  486. */
  487. int
  488. xfs_setattr_nonsize(
  489. struct xfs_inode *ip,
  490. struct iattr *iattr,
  491. int flags)
  492. {
  493. xfs_mount_t *mp = ip->i_mount;
  494. struct inode *inode = VFS_I(ip);
  495. int mask = iattr->ia_valid;
  496. xfs_trans_t *tp;
  497. int error;
  498. kuid_t uid = GLOBAL_ROOT_UID, iuid = GLOBAL_ROOT_UID;
  499. kgid_t gid = GLOBAL_ROOT_GID, igid = GLOBAL_ROOT_GID;
  500. struct xfs_dquot *udqp = NULL, *gdqp = NULL;
  501. struct xfs_dquot *olddquot1 = NULL, *olddquot2 = NULL;
  502. ASSERT((mask & ATTR_SIZE) == 0);
  503. /*
  504. * If disk quotas is on, we make sure that the dquots do exist on disk,
  505. * before we start any other transactions. Trying to do this later
  506. * is messy. We don't care to take a readlock to look at the ids
  507. * in inode here, because we can't hold it across the trans_reserve.
  508. * If the IDs do change before we take the ilock, we're covered
  509. * because the i_*dquot fields will get updated anyway.
  510. */
  511. if (XFS_IS_QUOTA_ON(mp) && (mask & (ATTR_UID|ATTR_GID))) {
  512. uint qflags = 0;
  513. if ((mask & ATTR_UID) && XFS_IS_UQUOTA_ON(mp)) {
  514. uid = iattr->ia_uid;
  515. qflags |= XFS_QMOPT_UQUOTA;
  516. } else {
  517. uid = inode->i_uid;
  518. }
  519. if ((mask & ATTR_GID) && XFS_IS_GQUOTA_ON(mp)) {
  520. gid = iattr->ia_gid;
  521. qflags |= XFS_QMOPT_GQUOTA;
  522. } else {
  523. gid = inode->i_gid;
  524. }
  525. /*
  526. * We take a reference when we initialize udqp and gdqp,
  527. * so it is important that we never blindly double trip on
  528. * the same variable. See xfs_create() for an example.
  529. */
  530. ASSERT(udqp == NULL);
  531. ASSERT(gdqp == NULL);
  532. error = xfs_qm_vop_dqalloc(ip, xfs_kuid_to_uid(uid),
  533. xfs_kgid_to_gid(gid),
  534. xfs_get_projid(ip),
  535. qflags, &udqp, &gdqp, NULL);
  536. if (error)
  537. return error;
  538. }
  539. error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp);
  540. if (error)
  541. goto out_dqrele;
  542. xfs_ilock(ip, XFS_ILOCK_EXCL);
  543. xfs_trans_ijoin(tp, ip, 0);
  544. /*
  545. * Change file ownership. Must be the owner or privileged.
  546. */
  547. if (mask & (ATTR_UID|ATTR_GID)) {
  548. /*
  549. * These IDs could have changed since we last looked at them.
  550. * But, we're assured that if the ownership did change
  551. * while we didn't have the inode locked, inode's dquot(s)
  552. * would have changed also.
  553. */
  554. iuid = inode->i_uid;
  555. igid = inode->i_gid;
  556. gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
  557. uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
  558. /*
  559. * Do a quota reservation only if uid/gid is actually
  560. * going to change.
  561. */
  562. if (XFS_IS_QUOTA_RUNNING(mp) &&
  563. ((XFS_IS_UQUOTA_ON(mp) && !uid_eq(iuid, uid)) ||
  564. (XFS_IS_GQUOTA_ON(mp) && !gid_eq(igid, gid)))) {
  565. ASSERT(tp);
  566. error = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
  567. NULL, capable(CAP_FOWNER) ?
  568. XFS_QMOPT_FORCE_RES : 0);
  569. if (error) /* out of quota */
  570. goto out_cancel;
  571. }
  572. }
  573. /*
  574. * Change file ownership. Must be the owner or privileged.
  575. */
  576. if (mask & (ATTR_UID|ATTR_GID)) {
  577. /*
  578. * CAP_FSETID overrides the following restrictions:
  579. *
  580. * The set-user-ID and set-group-ID bits of a file will be
  581. * cleared upon successful return from chown()
  582. */
  583. if ((inode->i_mode & (S_ISUID|S_ISGID)) &&
  584. !capable(CAP_FSETID))
  585. inode->i_mode &= ~(S_ISUID|S_ISGID);
  586. /*
  587. * Change the ownerships and register quota modifications
  588. * in the transaction.
  589. */
  590. if (!uid_eq(iuid, uid)) {
  591. if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
  592. ASSERT(mask & ATTR_UID);
  593. ASSERT(udqp);
  594. olddquot1 = xfs_qm_vop_chown(tp, ip,
  595. &ip->i_udquot, udqp);
  596. }
  597. ip->i_d.di_uid = xfs_kuid_to_uid(uid);
  598. inode->i_uid = uid;
  599. }
  600. if (!gid_eq(igid, gid)) {
  601. if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) {
  602. ASSERT(xfs_sb_version_has_pquotino(&mp->m_sb) ||
  603. !XFS_IS_PQUOTA_ON(mp));
  604. ASSERT(mask & ATTR_GID);
  605. ASSERT(gdqp);
  606. olddquot2 = xfs_qm_vop_chown(tp, ip,
  607. &ip->i_gdquot, gdqp);
  608. }
  609. ip->i_d.di_gid = xfs_kgid_to_gid(gid);
  610. inode->i_gid = gid;
  611. }
  612. }
  613. if (mask & ATTR_MODE)
  614. xfs_setattr_mode(ip, iattr);
  615. if (mask & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME))
  616. xfs_setattr_time(ip, iattr);
  617. xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
  618. XFS_STATS_INC(mp, xs_ig_attrchg);
  619. if (mp->m_flags & XFS_MOUNT_WSYNC)
  620. xfs_trans_set_sync(tp);
  621. error = xfs_trans_commit(tp);
  622. xfs_iunlock(ip, XFS_ILOCK_EXCL);
  623. /*
  624. * Release any dquot(s) the inode had kept before chown.
  625. */
  626. xfs_qm_dqrele(olddquot1);
  627. xfs_qm_dqrele(olddquot2);
  628. xfs_qm_dqrele(udqp);
  629. xfs_qm_dqrele(gdqp);
  630. if (error)
  631. return error;
  632. /*
  633. * XXX(hch): Updating the ACL entries is not atomic vs the i_mode
  634. * update. We could avoid this with linked transactions
  635. * and passing down the transaction pointer all the way
  636. * to attr_set. No previous user of the generic
  637. * Posix ACL code seems to care about this issue either.
  638. */
  639. if ((mask & ATTR_MODE) && !(flags & XFS_ATTR_NOACL)) {
  640. error = posix_acl_chmod(inode, inode->i_mode);
  641. if (error)
  642. return error;
  643. }
  644. return 0;
  645. out_cancel:
  646. xfs_trans_cancel(tp);
  647. out_dqrele:
  648. xfs_qm_dqrele(udqp);
  649. xfs_qm_dqrele(gdqp);
  650. return error;
  651. }
  652. int
  653. xfs_vn_setattr_nonsize(
  654. struct dentry *dentry,
  655. struct iattr *iattr)
  656. {
  657. struct xfs_inode *ip = XFS_I(d_inode(dentry));
  658. int error;
  659. trace_xfs_setattr(ip);
  660. error = xfs_vn_change_ok(dentry, iattr);
  661. if (error)
  662. return error;
  663. return xfs_setattr_nonsize(ip, iattr, 0);
  664. }
  665. /*
  666. * Truncate file. Must have write permission and not be a directory.
  667. *
  668. * Caution: The caller of this function is responsible for calling
  669. * setattr_prepare() or otherwise verifying the change is fine.
  670. */
  671. int
  672. xfs_setattr_size(
  673. struct xfs_inode *ip,
  674. struct iattr *iattr)
  675. {
  676. struct xfs_mount *mp = ip->i_mount;
  677. struct inode *inode = VFS_I(ip);
  678. xfs_off_t oldsize, newsize;
  679. struct xfs_trans *tp;
  680. int error;
  681. uint lock_flags = 0;
  682. bool did_zeroing = false;
  683. ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
  684. ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL));
  685. ASSERT(S_ISREG(inode->i_mode));
  686. ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
  687. ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0);
  688. oldsize = inode->i_size;
  689. newsize = iattr->ia_size;
  690. /*
  691. * Short circuit the truncate case for zero length files.
  692. */
  693. if (newsize == 0 && oldsize == 0 && ip->i_d.di_nextents == 0) {
  694. if (!(iattr->ia_valid & (ATTR_CTIME|ATTR_MTIME)))
  695. return 0;
  696. /*
  697. * Use the regular setattr path to update the timestamps.
  698. */
  699. iattr->ia_valid &= ~ATTR_SIZE;
  700. return xfs_setattr_nonsize(ip, iattr, 0);
  701. }
  702. /*
  703. * Make sure that the dquots are attached to the inode.
  704. */
  705. error = xfs_qm_dqattach(ip, 0);
  706. if (error)
  707. return error;
  708. /*
  709. * Wait for all direct I/O to complete.
  710. */
  711. inode_dio_wait(inode);
  712. /*
  713. * File data changes must be complete before we start the transaction to
  714. * modify the inode. This needs to be done before joining the inode to
  715. * the transaction because the inode cannot be unlocked once it is a
  716. * part of the transaction.
  717. *
  718. * Start with zeroing any data beyond EOF that we may expose on file
  719. * extension, or zeroing out the rest of the block on a downward
  720. * truncate.
  721. */
  722. if (newsize > oldsize) {
  723. error = xfs_zero_eof(ip, newsize, oldsize, &did_zeroing);
  724. } else {
  725. error = iomap_truncate_page(inode, newsize, &did_zeroing,
  726. &xfs_iomap_ops);
  727. }
  728. if (error)
  729. return error;
  730. /*
  731. * We are going to log the inode size change in this transaction so
  732. * any previous writes that are beyond the on disk EOF and the new
  733. * EOF that have not been written out need to be written here. If we
  734. * do not write the data out, we expose ourselves to the null files
  735. * problem. Note that this includes any block zeroing we did above;
  736. * otherwise those blocks may not be zeroed after a crash.
  737. */
  738. if (did_zeroing ||
  739. (newsize > ip->i_d.di_size && oldsize != ip->i_d.di_size)) {
  740. error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
  741. ip->i_d.di_size, newsize);
  742. if (error)
  743. return error;
  744. }
  745. /*
  746. * We've already locked out new page faults, so now we can safely remove
  747. * pages from the page cache knowing they won't get refaulted until we
  748. * drop the XFS_MMAP_EXCL lock after the extent manipulations are
  749. * complete. The truncate_setsize() call also cleans partial EOF page
  750. * PTEs on extending truncates and hence ensures sub-page block size
  751. * filesystems are correctly handled, too.
  752. *
  753. * We have to do all the page cache truncate work outside the
  754. * transaction context as the "lock" order is page lock->log space
  755. * reservation as defined by extent allocation in the writeback path.
  756. * Hence a truncate can fail with ENOMEM from xfs_trans_alloc(), but
  757. * having already truncated the in-memory version of the file (i.e. made
  758. * user visible changes). There's not much we can do about this, except
  759. * to hope that the caller sees ENOMEM and retries the truncate
  760. * operation.
  761. */
  762. truncate_setsize(inode, newsize);
  763. error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
  764. if (error)
  765. return error;
  766. lock_flags |= XFS_ILOCK_EXCL;
  767. xfs_ilock(ip, XFS_ILOCK_EXCL);
  768. xfs_trans_ijoin(tp, ip, 0);
  769. /*
  770. * Only change the c/mtime if we are changing the size or we are
  771. * explicitly asked to change it. This handles the semantic difference
  772. * between truncate() and ftruncate() as implemented in the VFS.
  773. *
  774. * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a
  775. * special case where we need to update the times despite not having
  776. * these flags set. For all other operations the VFS set these flags
  777. * explicitly if it wants a timestamp update.
  778. */
  779. if (newsize != oldsize &&
  780. !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) {
  781. iattr->ia_ctime = iattr->ia_mtime =
  782. current_time(inode);
  783. iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME;
  784. }
  785. /*
  786. * The first thing we do is set the size to new_size permanently on
  787. * disk. This way we don't have to worry about anyone ever being able
  788. * to look at the data being freed even in the face of a crash.
  789. * What we're getting around here is the case where we free a block, it
  790. * is allocated to another file, it is written to, and then we crash.
  791. * If the new data gets written to the file but the log buffers
  792. * containing the free and reallocation don't, then we'd end up with
  793. * garbage in the blocks being freed. As long as we make the new size
  794. * permanent before actually freeing any blocks it doesn't matter if
  795. * they get written to.
  796. */
  797. ip->i_d.di_size = newsize;
  798. xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
  799. if (newsize <= oldsize) {
  800. error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, newsize);
  801. if (error)
  802. goto out_trans_cancel;
  803. /*
  804. * Truncated "down", so we're removing references to old data
  805. * here - if we delay flushing for a long time, we expose
  806. * ourselves unduly to the notorious NULL files problem. So,
  807. * we mark this inode and flush it when the file is closed,
  808. * and do not wait the usual (long) time for writeout.
  809. */
  810. xfs_iflags_set(ip, XFS_ITRUNCATED);
  811. /* A truncate down always removes post-EOF blocks. */
  812. xfs_inode_clear_eofblocks_tag(ip);
  813. }
  814. if (iattr->ia_valid & ATTR_MODE)
  815. xfs_setattr_mode(ip, iattr);
  816. if (iattr->ia_valid & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME))
  817. xfs_setattr_time(ip, iattr);
  818. xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
  819. XFS_STATS_INC(mp, xs_ig_attrchg);
  820. if (mp->m_flags & XFS_MOUNT_WSYNC)
  821. xfs_trans_set_sync(tp);
  822. error = xfs_trans_commit(tp);
  823. out_unlock:
  824. if (lock_flags)
  825. xfs_iunlock(ip, lock_flags);
  826. return error;
  827. out_trans_cancel:
  828. xfs_trans_cancel(tp);
  829. goto out_unlock;
  830. }
  831. int
  832. xfs_vn_setattr_size(
  833. struct dentry *dentry,
  834. struct iattr *iattr)
  835. {
  836. struct xfs_inode *ip = XFS_I(d_inode(dentry));
  837. int error;
  838. trace_xfs_setattr(ip);
  839. error = xfs_vn_change_ok(dentry, iattr);
  840. if (error)
  841. return error;
  842. return xfs_setattr_size(ip, iattr);
  843. }
  844. STATIC int
  845. xfs_vn_setattr(
  846. struct dentry *dentry,
  847. struct iattr *iattr)
  848. {
  849. int error;
  850. if (iattr->ia_valid & ATTR_SIZE) {
  851. struct xfs_inode *ip = XFS_I(d_inode(dentry));
  852. uint iolock = XFS_IOLOCK_EXCL;
  853. error = xfs_break_layouts(d_inode(dentry), &iolock);
  854. if (error)
  855. return error;
  856. xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
  857. error = xfs_setattr_size(ip, iattr);
  858. xfs_iunlock(ip, XFS_MMAPLOCK_EXCL);
  859. } else {
  860. error = xfs_vn_setattr_nonsize(dentry, iattr);
  861. }
  862. return error;
  863. }
  864. STATIC int
  865. xfs_vn_update_time(
  866. struct inode *inode,
  867. struct timespec *now,
  868. int flags)
  869. {
  870. struct xfs_inode *ip = XFS_I(inode);
  871. struct xfs_mount *mp = ip->i_mount;
  872. struct xfs_trans *tp;
  873. int error;
  874. trace_xfs_update_time(ip);
  875. error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);
  876. if (error)
  877. return error;
  878. xfs_ilock(ip, XFS_ILOCK_EXCL);
  879. if (flags & S_CTIME)
  880. inode->i_ctime = *now;
  881. if (flags & S_MTIME)
  882. inode->i_mtime = *now;
  883. if (flags & S_ATIME)
  884. inode->i_atime = *now;
  885. xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
  886. xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
  887. return xfs_trans_commit(tp);
  888. }
  889. STATIC int
  890. xfs_vn_fiemap(
  891. struct inode *inode,
  892. struct fiemap_extent_info *fieinfo,
  893. u64 start,
  894. u64 length)
  895. {
  896. int error;
  897. xfs_ilock(XFS_I(inode), XFS_IOLOCK_SHARED);
  898. if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
  899. fieinfo->fi_flags &= ~FIEMAP_FLAG_XATTR;
  900. error = iomap_fiemap(inode, fieinfo, start, length,
  901. &xfs_xattr_iomap_ops);
  902. } else {
  903. error = iomap_fiemap(inode, fieinfo, start, length,
  904. &xfs_iomap_ops);
  905. }
  906. xfs_iunlock(XFS_I(inode), XFS_IOLOCK_SHARED);
  907. return error;
  908. }
  909. STATIC int
  910. xfs_vn_tmpfile(
  911. struct inode *dir,
  912. struct dentry *dentry,
  913. umode_t mode)
  914. {
  915. return xfs_generic_create(dir, dentry, mode, 0, true);
  916. }
  917. static const struct inode_operations xfs_inode_operations = {
  918. .get_acl = xfs_get_acl,
  919. .set_acl = xfs_set_acl,
  920. .getattr = xfs_vn_getattr,
  921. .setattr = xfs_vn_setattr,
  922. .listxattr = xfs_vn_listxattr,
  923. .fiemap = xfs_vn_fiemap,
  924. .update_time = xfs_vn_update_time,
  925. };
  926. static const struct inode_operations xfs_dir_inode_operations = {
  927. .create = xfs_vn_create,
  928. .lookup = xfs_vn_lookup,
  929. .link = xfs_vn_link,
  930. .unlink = xfs_vn_unlink,
  931. .symlink = xfs_vn_symlink,
  932. .mkdir = xfs_vn_mkdir,
  933. /*
  934. * Yes, XFS uses the same method for rmdir and unlink.
  935. *
  936. * There are some subtile differences deeper in the code,
  937. * but we use S_ISDIR to check for those.
  938. */
  939. .rmdir = xfs_vn_unlink,
  940. .mknod = xfs_vn_mknod,
  941. .rename = xfs_vn_rename,
  942. .get_acl = xfs_get_acl,
  943. .set_acl = xfs_set_acl,
  944. .getattr = xfs_vn_getattr,
  945. .setattr = xfs_vn_setattr,
  946. .listxattr = xfs_vn_listxattr,
  947. .update_time = xfs_vn_update_time,
  948. .tmpfile = xfs_vn_tmpfile,
  949. };
  950. static const struct inode_operations xfs_dir_ci_inode_operations = {
  951. .create = xfs_vn_create,
  952. .lookup = xfs_vn_ci_lookup,
  953. .link = xfs_vn_link,
  954. .unlink = xfs_vn_unlink,
  955. .symlink = xfs_vn_symlink,
  956. .mkdir = xfs_vn_mkdir,
  957. /*
  958. * Yes, XFS uses the same method for rmdir and unlink.
  959. *
  960. * There are some subtile differences deeper in the code,
  961. * but we use S_ISDIR to check for those.
  962. */
  963. .rmdir = xfs_vn_unlink,
  964. .mknod = xfs_vn_mknod,
  965. .rename = xfs_vn_rename,
  966. .get_acl = xfs_get_acl,
  967. .set_acl = xfs_set_acl,
  968. .getattr = xfs_vn_getattr,
  969. .setattr = xfs_vn_setattr,
  970. .listxattr = xfs_vn_listxattr,
  971. .update_time = xfs_vn_update_time,
  972. .tmpfile = xfs_vn_tmpfile,
  973. };
  974. static const struct inode_operations xfs_symlink_inode_operations = {
  975. .readlink = generic_readlink,
  976. .get_link = xfs_vn_get_link,
  977. .getattr = xfs_vn_getattr,
  978. .setattr = xfs_vn_setattr,
  979. .listxattr = xfs_vn_listxattr,
  980. .update_time = xfs_vn_update_time,
  981. };
  982. static const struct inode_operations xfs_inline_symlink_inode_operations = {
  983. .readlink = generic_readlink,
  984. .get_link = xfs_vn_get_link_inline,
  985. .getattr = xfs_vn_getattr,
  986. .setattr = xfs_vn_setattr,
  987. .listxattr = xfs_vn_listxattr,
  988. .update_time = xfs_vn_update_time,
  989. };
  990. STATIC void
  991. xfs_diflags_to_iflags(
  992. struct inode *inode,
  993. struct xfs_inode *ip)
  994. {
  995. uint16_t flags = ip->i_d.di_flags;
  996. inode->i_flags &= ~(S_IMMUTABLE | S_APPEND | S_SYNC |
  997. S_NOATIME | S_DAX);
  998. if (flags & XFS_DIFLAG_IMMUTABLE)
  999. inode->i_flags |= S_IMMUTABLE;
  1000. if (flags & XFS_DIFLAG_APPEND)
  1001. inode->i_flags |= S_APPEND;
  1002. if (flags & XFS_DIFLAG_SYNC)
  1003. inode->i_flags |= S_SYNC;
  1004. if (flags & XFS_DIFLAG_NOATIME)
  1005. inode->i_flags |= S_NOATIME;
  1006. if (S_ISREG(inode->i_mode) &&
  1007. ip->i_mount->m_sb.sb_blocksize == PAGE_SIZE &&
  1008. !xfs_is_reflink_inode(ip) &&
  1009. (ip->i_mount->m_flags & XFS_MOUNT_DAX ||
  1010. ip->i_d.di_flags2 & XFS_DIFLAG2_DAX))
  1011. inode->i_flags |= S_DAX;
  1012. }
  1013. /*
  1014. * Initialize the Linux inode.
  1015. *
  1016. * When reading existing inodes from disk this is called directly from xfs_iget,
  1017. * when creating a new inode it is called from xfs_ialloc after setting up the
  1018. * inode. These callers have different criteria for clearing XFS_INEW, so leave
  1019. * it up to the caller to deal with unlocking the inode appropriately.
  1020. */
  1021. void
  1022. xfs_setup_inode(
  1023. struct xfs_inode *ip)
  1024. {
  1025. struct inode *inode = &ip->i_vnode;
  1026. gfp_t gfp_mask;
  1027. inode->i_ino = ip->i_ino;
  1028. inode->i_state = I_NEW;
  1029. inode_sb_list_add(inode);
  1030. /* make the inode look hashed for the writeback code */
  1031. hlist_add_fake(&inode->i_hash);
  1032. inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid);
  1033. inode->i_gid = xfs_gid_to_kgid(ip->i_d.di_gid);
  1034. switch (inode->i_mode & S_IFMT) {
  1035. case S_IFBLK:
  1036. case S_IFCHR:
  1037. inode->i_rdev =
  1038. MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
  1039. sysv_minor(ip->i_df.if_u2.if_rdev));
  1040. break;
  1041. default:
  1042. inode->i_rdev = 0;
  1043. break;
  1044. }
  1045. i_size_write(inode, ip->i_d.di_size);
  1046. xfs_diflags_to_iflags(inode, ip);
  1047. if (S_ISDIR(inode->i_mode)) {
  1048. lockdep_set_class(&ip->i_lock.mr_lock, &xfs_dir_ilock_class);
  1049. ip->d_ops = ip->i_mount->m_dir_inode_ops;
  1050. } else {
  1051. ip->d_ops = ip->i_mount->m_nondir_inode_ops;
  1052. lockdep_set_class(&ip->i_lock.mr_lock, &xfs_nondir_ilock_class);
  1053. }
  1054. /*
  1055. * Ensure all page cache allocations are done from GFP_NOFS context to
  1056. * prevent direct reclaim recursion back into the filesystem and blowing
  1057. * stacks or deadlocking.
  1058. */
  1059. gfp_mask = mapping_gfp_mask(inode->i_mapping);
  1060. mapping_set_gfp_mask(inode->i_mapping, (gfp_mask & ~(__GFP_FS)));
  1061. /*
  1062. * If there is no attribute fork no ACL can exist on this inode,
  1063. * and it can't have any file capabilities attached to it either.
  1064. */
  1065. if (!XFS_IFORK_Q(ip)) {
  1066. inode_has_no_xattr(inode);
  1067. cache_no_acl(inode);
  1068. }
  1069. }
  1070. void
  1071. xfs_setup_iops(
  1072. struct xfs_inode *ip)
  1073. {
  1074. struct inode *inode = &ip->i_vnode;
  1075. switch (inode->i_mode & S_IFMT) {
  1076. case S_IFREG:
  1077. inode->i_op = &xfs_inode_operations;
  1078. inode->i_fop = &xfs_file_operations;
  1079. inode->i_mapping->a_ops = &xfs_address_space_operations;
  1080. break;
  1081. case S_IFDIR:
  1082. if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
  1083. inode->i_op = &xfs_dir_ci_inode_operations;
  1084. else
  1085. inode->i_op = &xfs_dir_inode_operations;
  1086. inode->i_fop = &xfs_dir_file_operations;
  1087. break;
  1088. case S_IFLNK:
  1089. if (ip->i_df.if_flags & XFS_IFINLINE)
  1090. inode->i_op = &xfs_inline_symlink_inode_operations;
  1091. else
  1092. inode->i_op = &xfs_symlink_inode_operations;
  1093. break;
  1094. default:
  1095. inode->i_op = &xfs_inode_operations;
  1096. init_special_inode(inode, inode->i_mode, inode->i_rdev);
  1097. break;
  1098. }
  1099. }