inode.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303
  1. /*
  2. * Copyright (C) 2005, 2006
  3. * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com)
  4. * Copyright (C) 2005, 2006
  5. * International Business Machines
  6. * Copyright (C) 2008, 2009
  7. * Boaz Harrosh <bharrosh@panasas.com>
  8. *
  9. * Copyrights for code taken from ext2:
  10. * Copyright (C) 1992, 1993, 1994, 1995
  11. * Remy Card (card@masi.ibp.fr)
  12. * Laboratoire MASI - Institut Blaise Pascal
  13. * Universite Pierre et Marie Curie (Paris VI)
  14. * from
  15. * linux/fs/minix/inode.c
  16. * Copyright (C) 1991, 1992 Linus Torvalds
  17. *
  18. * This file is part of exofs.
  19. *
  20. * exofs is free software; you can redistribute it and/or modify
  21. * it under the terms of the GNU General Public License as published by
  22. * the Free Software Foundation. Since it is based on ext2, and the only
  23. * valid version of GPL for the Linux kernel is version 2, the only valid
  24. * version of GPL for exofs is version 2.
  25. *
  26. * exofs is distributed in the hope that it will be useful,
  27. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. * GNU General Public License for more details.
  30. *
  31. * You should have received a copy of the GNU General Public License
  32. * along with exofs; if not, write to the Free Software
  33. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  34. */
  35. #include <linux/writeback.h>
  36. #include <linux/buffer_head.h>
  37. #include <scsi/scsi_device.h>
  38. #include "exofs.h"
  39. #ifdef CONFIG_EXOFS_DEBUG
  40. # define EXOFS_DEBUG_OBJ_ISIZE 1
  41. #endif
  42. struct page_collect {
  43. struct exofs_sb_info *sbi;
  44. struct request_queue *req_q;
  45. struct inode *inode;
  46. unsigned expected_pages;
  47. struct bio *bio;
  48. unsigned nr_pages;
  49. unsigned long length;
  50. loff_t pg_first; /* keep 64bit also in 32-arches */
  51. };
  52. static void _pcol_init(struct page_collect *pcol, unsigned expected_pages,
  53. struct inode *inode)
  54. {
  55. struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
  56. struct request_queue *req_q = sbi->s_dev->scsi_device->request_queue;
  57. pcol->sbi = sbi;
  58. pcol->req_q = req_q;
  59. pcol->inode = inode;
  60. pcol->expected_pages = expected_pages;
  61. pcol->bio = NULL;
  62. pcol->nr_pages = 0;
  63. pcol->length = 0;
  64. pcol->pg_first = -1;
  65. EXOFS_DBGMSG("_pcol_init ino=0x%lx expected_pages=%u\n", inode->i_ino,
  66. expected_pages);
  67. }
  68. static void _pcol_reset(struct page_collect *pcol)
  69. {
  70. pcol->expected_pages -= min(pcol->nr_pages, pcol->expected_pages);
  71. pcol->bio = NULL;
  72. pcol->nr_pages = 0;
  73. pcol->length = 0;
  74. pcol->pg_first = -1;
  75. EXOFS_DBGMSG("_pcol_reset ino=0x%lx expected_pages=%u\n",
  76. pcol->inode->i_ino, pcol->expected_pages);
  77. /* this is probably the end of the loop but in writes
  78. * it might not end here. don't be left with nothing
  79. */
  80. if (!pcol->expected_pages)
  81. pcol->expected_pages = 128;
  82. }
  83. static int pcol_try_alloc(struct page_collect *pcol)
  84. {
  85. int pages = min_t(unsigned, pcol->expected_pages, BIO_MAX_PAGES);
  86. for (; pages; pages >>= 1) {
  87. pcol->bio = bio_alloc(GFP_KERNEL, pages);
  88. if (likely(pcol->bio))
  89. return 0;
  90. }
  91. EXOFS_ERR("Failed to kcalloc expected_pages=%u\n",
  92. pcol->expected_pages);
  93. return -ENOMEM;
  94. }
  95. static void pcol_free(struct page_collect *pcol)
  96. {
  97. bio_put(pcol->bio);
  98. pcol->bio = NULL;
  99. }
  100. static int pcol_add_page(struct page_collect *pcol, struct page *page,
  101. unsigned len)
  102. {
  103. int added_len = bio_add_pc_page(pcol->req_q, pcol->bio, page, len, 0);
  104. if (unlikely(len != added_len))
  105. return -ENOMEM;
  106. ++pcol->nr_pages;
  107. pcol->length += len;
  108. return 0;
  109. }
  110. static int update_read_page(struct page *page, int ret)
  111. {
  112. if (ret == 0) {
  113. /* Everything is OK */
  114. SetPageUptodate(page);
  115. if (PageError(page))
  116. ClearPageError(page);
  117. } else if (ret == -EFAULT) {
  118. /* In this case we were trying to read something that wasn't on
  119. * disk yet - return a page full of zeroes. This should be OK,
  120. * because the object should be empty (if there was a write
  121. * before this read, the read would be waiting with the page
  122. * locked */
  123. clear_highpage(page);
  124. SetPageUptodate(page);
  125. if (PageError(page))
  126. ClearPageError(page);
  127. ret = 0; /* recovered error */
  128. EXOFS_DBGMSG("recovered read error\n");
  129. } else /* Error */
  130. SetPageError(page);
  131. return ret;
  132. }
  133. static void update_write_page(struct page *page, int ret)
  134. {
  135. if (ret) {
  136. mapping_set_error(page->mapping, ret);
  137. SetPageError(page);
  138. }
  139. end_page_writeback(page);
  140. }
  141. /* Called at the end of reads, to optionally unlock pages and update their
  142. * status.
  143. */
  144. static int __readpages_done(struct osd_request *or, struct page_collect *pcol,
  145. bool do_unlock)
  146. {
  147. struct bio_vec *bvec;
  148. int i;
  149. u64 resid;
  150. u64 good_bytes;
  151. u64 length = 0;
  152. int ret = exofs_check_ok_resid(or, &resid, NULL);
  153. osd_end_request(or);
  154. if (likely(!ret))
  155. good_bytes = pcol->length;
  156. else if (!resid)
  157. good_bytes = 0;
  158. else
  159. good_bytes = pcol->length - resid;
  160. EXOFS_DBGMSG("readpages_done(0x%lx) good_bytes=0x%llx"
  161. " length=0x%lx nr_pages=%u\n",
  162. pcol->inode->i_ino, _LLU(good_bytes), pcol->length,
  163. pcol->nr_pages);
  164. __bio_for_each_segment(bvec, pcol->bio, i, 0) {
  165. struct page *page = bvec->bv_page;
  166. struct inode *inode = page->mapping->host;
  167. int page_stat;
  168. if (inode != pcol->inode)
  169. continue; /* osd might add more pages at end */
  170. if (likely(length < good_bytes))
  171. page_stat = 0;
  172. else
  173. page_stat = ret;
  174. EXOFS_DBGMSG(" readpages_done(0x%lx, 0x%lx) %s\n",
  175. inode->i_ino, page->index,
  176. page_stat ? "bad_bytes" : "good_bytes");
  177. ret = update_read_page(page, page_stat);
  178. if (do_unlock)
  179. unlock_page(page);
  180. length += bvec->bv_len;
  181. }
  182. pcol_free(pcol);
  183. EXOFS_DBGMSG("readpages_done END\n");
  184. return ret;
  185. }
  186. /* callback of async reads */
  187. static void readpages_done(struct osd_request *or, void *p)
  188. {
  189. struct page_collect *pcol = p;
  190. __readpages_done(or, pcol, true);
  191. atomic_dec(&pcol->sbi->s_curr_pending);
  192. kfree(p);
  193. }
  194. static void _unlock_pcol_pages(struct page_collect *pcol, int ret, int rw)
  195. {
  196. struct bio_vec *bvec;
  197. int i;
  198. __bio_for_each_segment(bvec, pcol->bio, i, 0) {
  199. struct page *page = bvec->bv_page;
  200. if (rw == READ)
  201. update_read_page(page, ret);
  202. else
  203. update_write_page(page, ret);
  204. unlock_page(page);
  205. }
  206. pcol_free(pcol);
  207. }
  208. static int read_exec(struct page_collect *pcol, bool is_sync)
  209. {
  210. struct exofs_i_info *oi = exofs_i(pcol->inode);
  211. struct osd_obj_id obj = {pcol->sbi->s_pid,
  212. pcol->inode->i_ino + EXOFS_OBJ_OFF};
  213. struct osd_request *or = NULL;
  214. struct page_collect *pcol_copy = NULL;
  215. loff_t i_start = pcol->pg_first << PAGE_CACHE_SHIFT;
  216. int ret;
  217. if (!pcol->bio)
  218. return 0;
  219. /* see comment in _readpage() about sync reads */
  220. WARN_ON(is_sync && (pcol->nr_pages != 1));
  221. or = osd_start_request(pcol->sbi->s_dev, GFP_KERNEL);
  222. if (unlikely(!or)) {
  223. ret = -ENOMEM;
  224. goto err;
  225. }
  226. osd_req_read(or, &obj, pcol->bio, i_start);
  227. if (is_sync) {
  228. exofs_sync_op(or, pcol->sbi->s_timeout, oi->i_cred);
  229. return __readpages_done(or, pcol, false);
  230. }
  231. pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL);
  232. if (!pcol_copy) {
  233. ret = -ENOMEM;
  234. goto err;
  235. }
  236. *pcol_copy = *pcol;
  237. ret = exofs_async_op(or, readpages_done, pcol_copy, oi->i_cred);
  238. if (unlikely(ret))
  239. goto err;
  240. atomic_inc(&pcol->sbi->s_curr_pending);
  241. EXOFS_DBGMSG("read_exec obj=0x%llx start=0x%llx length=0x%lx\n",
  242. obj.id, _LLU(i_start), pcol->length);
  243. /* pages ownership was passed to pcol_copy */
  244. _pcol_reset(pcol);
  245. return 0;
  246. err:
  247. if (!is_sync)
  248. _unlock_pcol_pages(pcol, ret, READ);
  249. kfree(pcol_copy);
  250. if (or)
  251. osd_end_request(or);
  252. return ret;
  253. }
  254. /* readpage_strip is called either directly from readpage() or by the VFS from
  255. * within read_cache_pages(), to add one more page to be read. It will try to
  256. * collect as many contiguous pages as posible. If a discontinuity is
  257. * encountered, or it runs out of resources, it will submit the previous segment
  258. * and will start a new collection. Eventually caller must submit the last
  259. * segment if present.
  260. */
  261. static int readpage_strip(void *data, struct page *page)
  262. {
  263. struct page_collect *pcol = data;
  264. struct inode *inode = pcol->inode;
  265. struct exofs_i_info *oi = exofs_i(inode);
  266. loff_t i_size = i_size_read(inode);
  267. pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
  268. size_t len;
  269. int ret;
  270. /* FIXME: Just for debugging, will be removed */
  271. if (PageUptodate(page))
  272. EXOFS_ERR("PageUptodate(0x%lx, 0x%lx)\n", pcol->inode->i_ino,
  273. page->index);
  274. if (page->index < end_index)
  275. len = PAGE_CACHE_SIZE;
  276. else if (page->index == end_index)
  277. len = i_size & ~PAGE_CACHE_MASK;
  278. else
  279. len = 0;
  280. if (!len || !obj_created(oi)) {
  281. /* this will be out of bounds, or doesn't exist yet.
  282. * Current page is cleared and the request is split
  283. */
  284. clear_highpage(page);
  285. SetPageUptodate(page);
  286. if (PageError(page))
  287. ClearPageError(page);
  288. unlock_page(page);
  289. EXOFS_DBGMSG("readpage_strip(0x%lx, 0x%lx) empty page,"
  290. " splitting\n", inode->i_ino, page->index);
  291. return read_exec(pcol, false);
  292. }
  293. try_again:
  294. if (unlikely(pcol->pg_first == -1)) {
  295. pcol->pg_first = page->index;
  296. } else if (unlikely((pcol->pg_first + pcol->nr_pages) !=
  297. page->index)) {
  298. /* Discontinuity detected, split the request */
  299. ret = read_exec(pcol, false);
  300. if (unlikely(ret))
  301. goto fail;
  302. goto try_again;
  303. }
  304. if (!pcol->bio) {
  305. ret = pcol_try_alloc(pcol);
  306. if (unlikely(ret))
  307. goto fail;
  308. }
  309. if (len != PAGE_CACHE_SIZE)
  310. zero_user(page, len, PAGE_CACHE_SIZE - len);
  311. EXOFS_DBGMSG(" readpage_strip(0x%lx, 0x%lx) len=0x%zx\n",
  312. inode->i_ino, page->index, len);
  313. ret = pcol_add_page(pcol, page, len);
  314. if (ret) {
  315. EXOFS_DBGMSG("Failed pcol_add_page pages[i]=%p "
  316. "this_len=0x%zx nr_pages=%u length=0x%lx\n",
  317. page, len, pcol->nr_pages, pcol->length);
  318. /* split the request, and start again with current page */
  319. ret = read_exec(pcol, false);
  320. if (unlikely(ret))
  321. goto fail;
  322. goto try_again;
  323. }
  324. return 0;
  325. fail:
  326. /* SetPageError(page); ??? */
  327. unlock_page(page);
  328. return ret;
  329. }
  330. static int exofs_readpages(struct file *file, struct address_space *mapping,
  331. struct list_head *pages, unsigned nr_pages)
  332. {
  333. struct page_collect pcol;
  334. int ret;
  335. _pcol_init(&pcol, nr_pages, mapping->host);
  336. ret = read_cache_pages(mapping, pages, readpage_strip, &pcol);
  337. if (ret) {
  338. EXOFS_ERR("read_cache_pages => %d\n", ret);
  339. return ret;
  340. }
  341. return read_exec(&pcol, false);
  342. }
  343. static int _readpage(struct page *page, bool is_sync)
  344. {
  345. struct page_collect pcol;
  346. int ret;
  347. _pcol_init(&pcol, 1, page->mapping->host);
  348. /* readpage_strip might call read_exec(,async) inside at several places
  349. * but this is safe for is_async=0 since read_exec will not do anything
  350. * when we have a single page.
  351. */
  352. ret = readpage_strip(&pcol, page);
  353. if (ret) {
  354. EXOFS_ERR("_readpage => %d\n", ret);
  355. return ret;
  356. }
  357. return read_exec(&pcol, is_sync);
  358. }
  359. /*
  360. * We don't need the file
  361. */
  362. static int exofs_readpage(struct file *file, struct page *page)
  363. {
  364. return _readpage(page, false);
  365. }
  366. /* Callback for osd_write. All writes are asynchronouse */
  367. static void writepages_done(struct osd_request *or, void *p)
  368. {
  369. struct page_collect *pcol = p;
  370. struct bio_vec *bvec;
  371. int i;
  372. u64 resid;
  373. u64 good_bytes;
  374. u64 length = 0;
  375. int ret = exofs_check_ok_resid(or, NULL, &resid);
  376. osd_end_request(or);
  377. atomic_dec(&pcol->sbi->s_curr_pending);
  378. if (likely(!ret))
  379. good_bytes = pcol->length;
  380. else if (!resid)
  381. good_bytes = 0;
  382. else
  383. good_bytes = pcol->length - resid;
  384. EXOFS_DBGMSG("writepages_done(0x%lx) good_bytes=0x%llx"
  385. " length=0x%lx nr_pages=%u\n",
  386. pcol->inode->i_ino, _LLU(good_bytes), pcol->length,
  387. pcol->nr_pages);
  388. __bio_for_each_segment(bvec, pcol->bio, i, 0) {
  389. struct page *page = bvec->bv_page;
  390. struct inode *inode = page->mapping->host;
  391. int page_stat;
  392. if (inode != pcol->inode)
  393. continue; /* osd might add more pages to a bio */
  394. if (likely(length < good_bytes))
  395. page_stat = 0;
  396. else
  397. page_stat = ret;
  398. update_write_page(page, page_stat);
  399. unlock_page(page);
  400. EXOFS_DBGMSG(" writepages_done(0x%lx, 0x%lx) status=%d\n",
  401. inode->i_ino, page->index, page_stat);
  402. length += bvec->bv_len;
  403. }
  404. pcol_free(pcol);
  405. kfree(pcol);
  406. EXOFS_DBGMSG("writepages_done END\n");
  407. }
  408. static int write_exec(struct page_collect *pcol)
  409. {
  410. struct exofs_i_info *oi = exofs_i(pcol->inode);
  411. struct osd_obj_id obj = {pcol->sbi->s_pid,
  412. pcol->inode->i_ino + EXOFS_OBJ_OFF};
  413. struct osd_request *or = NULL;
  414. struct page_collect *pcol_copy = NULL;
  415. loff_t i_start = pcol->pg_first << PAGE_CACHE_SHIFT;
  416. int ret;
  417. if (!pcol->bio)
  418. return 0;
  419. or = osd_start_request(pcol->sbi->s_dev, GFP_KERNEL);
  420. if (unlikely(!or)) {
  421. EXOFS_ERR("write_exec: Faild to osd_start_request()\n");
  422. ret = -ENOMEM;
  423. goto err;
  424. }
  425. pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL);
  426. if (!pcol_copy) {
  427. EXOFS_ERR("write_exec: Faild to kmalloc(pcol)\n");
  428. ret = -ENOMEM;
  429. goto err;
  430. }
  431. *pcol_copy = *pcol;
  432. osd_req_write(or, &obj, pcol_copy->bio, i_start);
  433. ret = exofs_async_op(or, writepages_done, pcol_copy, oi->i_cred);
  434. if (unlikely(ret)) {
  435. EXOFS_ERR("write_exec: exofs_async_op() Faild\n");
  436. goto err;
  437. }
  438. atomic_inc(&pcol->sbi->s_curr_pending);
  439. EXOFS_DBGMSG("write_exec(0x%lx, 0x%llx) start=0x%llx length=0x%lx\n",
  440. pcol->inode->i_ino, pcol->pg_first, _LLU(i_start),
  441. pcol->length);
  442. /* pages ownership was passed to pcol_copy */
  443. _pcol_reset(pcol);
  444. return 0;
  445. err:
  446. _unlock_pcol_pages(pcol, ret, WRITE);
  447. kfree(pcol_copy);
  448. if (or)
  449. osd_end_request(or);
  450. return ret;
  451. }
  452. /* writepage_strip is called either directly from writepage() or by the VFS from
  453. * within write_cache_pages(), to add one more page to be written to storage.
  454. * It will try to collect as many contiguous pages as possible. If a
  455. * discontinuity is encountered or it runs out of resources it will submit the
  456. * previous segment and will start a new collection.
  457. * Eventually caller must submit the last segment if present.
  458. */
  459. static int writepage_strip(struct page *page,
  460. struct writeback_control *wbc_unused, void *data)
  461. {
  462. struct page_collect *pcol = data;
  463. struct inode *inode = pcol->inode;
  464. struct exofs_i_info *oi = exofs_i(inode);
  465. loff_t i_size = i_size_read(inode);
  466. pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
  467. size_t len;
  468. int ret;
  469. BUG_ON(!PageLocked(page));
  470. ret = wait_obj_created(oi);
  471. if (unlikely(ret))
  472. goto fail;
  473. if (page->index < end_index)
  474. /* in this case, the page is within the limits of the file */
  475. len = PAGE_CACHE_SIZE;
  476. else {
  477. len = i_size & ~PAGE_CACHE_MASK;
  478. if (page->index > end_index || !len) {
  479. /* in this case, the page is outside the limits
  480. * (truncate in progress)
  481. */
  482. ret = write_exec(pcol);
  483. if (unlikely(ret))
  484. goto fail;
  485. if (PageError(page))
  486. ClearPageError(page);
  487. unlock_page(page);
  488. return 0;
  489. }
  490. }
  491. try_again:
  492. if (unlikely(pcol->pg_first == -1)) {
  493. pcol->pg_first = page->index;
  494. } else if (unlikely((pcol->pg_first + pcol->nr_pages) !=
  495. page->index)) {
  496. /* Discontinuity detected, split the request */
  497. ret = write_exec(pcol);
  498. if (unlikely(ret))
  499. goto fail;
  500. goto try_again;
  501. }
  502. if (!pcol->bio) {
  503. ret = pcol_try_alloc(pcol);
  504. if (unlikely(ret))
  505. goto fail;
  506. }
  507. EXOFS_DBGMSG(" writepage_strip(0x%lx, 0x%lx) len=0x%zx\n",
  508. inode->i_ino, page->index, len);
  509. ret = pcol_add_page(pcol, page, len);
  510. if (unlikely(ret)) {
  511. EXOFS_DBGMSG("Failed pcol_add_page "
  512. "nr_pages=%u total_length=0x%lx\n",
  513. pcol->nr_pages, pcol->length);
  514. /* split the request, next loop will start again */
  515. ret = write_exec(pcol);
  516. if (unlikely(ret)) {
  517. EXOFS_DBGMSG("write_exec faild => %d", ret);
  518. goto fail;
  519. }
  520. goto try_again;
  521. }
  522. BUG_ON(PageWriteback(page));
  523. set_page_writeback(page);
  524. return 0;
  525. fail:
  526. set_bit(AS_EIO, &page->mapping->flags);
  527. unlock_page(page);
  528. return ret;
  529. }
  530. static int exofs_writepages(struct address_space *mapping,
  531. struct writeback_control *wbc)
  532. {
  533. struct page_collect pcol;
  534. long start, end, expected_pages;
  535. int ret;
  536. start = wbc->range_start >> PAGE_CACHE_SHIFT;
  537. end = (wbc->range_end == LLONG_MAX) ?
  538. start + mapping->nrpages :
  539. wbc->range_end >> PAGE_CACHE_SHIFT;
  540. if (start || end)
  541. expected_pages = min(end - start + 1, 32L);
  542. else
  543. expected_pages = mapping->nrpages;
  544. EXOFS_DBGMSG("inode(0x%lx) wbc->start=0x%llx wbc->end=0x%llx"
  545. " m->nrpages=%lu start=0x%lx end=0x%lx\n",
  546. mapping->host->i_ino, wbc->range_start, wbc->range_end,
  547. mapping->nrpages, start, end);
  548. _pcol_init(&pcol, expected_pages, mapping->host);
  549. ret = write_cache_pages(mapping, wbc, writepage_strip, &pcol);
  550. if (ret) {
  551. EXOFS_ERR("write_cache_pages => %d\n", ret);
  552. return ret;
  553. }
  554. return write_exec(&pcol);
  555. }
  556. static int exofs_writepage(struct page *page, struct writeback_control *wbc)
  557. {
  558. struct page_collect pcol;
  559. int ret;
  560. _pcol_init(&pcol, 1, page->mapping->host);
  561. ret = writepage_strip(page, NULL, &pcol);
  562. if (ret) {
  563. EXOFS_ERR("exofs_writepage => %d\n", ret);
  564. return ret;
  565. }
  566. return write_exec(&pcol);
  567. }
  568. int exofs_write_begin(struct file *file, struct address_space *mapping,
  569. loff_t pos, unsigned len, unsigned flags,
  570. struct page **pagep, void **fsdata)
  571. {
  572. int ret = 0;
  573. struct page *page;
  574. page = *pagep;
  575. if (page == NULL) {
  576. ret = simple_write_begin(file, mapping, pos, len, flags, pagep,
  577. fsdata);
  578. if (ret) {
  579. EXOFS_DBGMSG("simple_write_begin faild\n");
  580. return ret;
  581. }
  582. page = *pagep;
  583. }
  584. /* read modify write */
  585. if (!PageUptodate(page) && (len != PAGE_CACHE_SIZE)) {
  586. ret = _readpage(page, true);
  587. if (ret) {
  588. /*SetPageError was done by _readpage. Is it ok?*/
  589. unlock_page(page);
  590. EXOFS_DBGMSG("__readpage_filler faild\n");
  591. }
  592. }
  593. return ret;
  594. }
  595. static int exofs_write_begin_export(struct file *file,
  596. struct address_space *mapping,
  597. loff_t pos, unsigned len, unsigned flags,
  598. struct page **pagep, void **fsdata)
  599. {
  600. *pagep = NULL;
  601. return exofs_write_begin(file, mapping, pos, len, flags, pagep,
  602. fsdata);
  603. }
  604. const struct address_space_operations exofs_aops = {
  605. .readpage = exofs_readpage,
  606. .readpages = exofs_readpages,
  607. .writepage = exofs_writepage,
  608. .writepages = exofs_writepages,
  609. .write_begin = exofs_write_begin_export,
  610. .write_end = simple_write_end,
  611. };
  612. /******************************************************************************
  613. * INODE OPERATIONS
  614. *****************************************************************************/
  615. /*
  616. * Test whether an inode is a fast symlink.
  617. */
  618. static inline int exofs_inode_is_fast_symlink(struct inode *inode)
  619. {
  620. struct exofs_i_info *oi = exofs_i(inode);
  621. return S_ISLNK(inode->i_mode) && (oi->i_data[0] != 0);
  622. }
  623. /*
  624. * get_block_t - Fill in a buffer_head
  625. * An OSD takes care of block allocation so we just fake an allocation by
  626. * putting in the inode's sector_t in the buffer_head.
  627. * TODO: What about the case of create==0 and @iblock does not exist in the
  628. * object?
  629. */
  630. static int exofs_get_block(struct inode *inode, sector_t iblock,
  631. struct buffer_head *bh_result, int create)
  632. {
  633. map_bh(bh_result, inode->i_sb, iblock);
  634. return 0;
  635. }
  636. const struct osd_attr g_attr_logical_length = ATTR_DEF(
  637. OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8);
  638. /*
  639. * Truncate a file to the specified size - all we have to do is set the size
  640. * attribute. We make sure the object exists first.
  641. */
  642. void exofs_truncate(struct inode *inode)
  643. {
  644. struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
  645. struct exofs_i_info *oi = exofs_i(inode);
  646. struct osd_obj_id obj = {sbi->s_pid, inode->i_ino + EXOFS_OBJ_OFF};
  647. struct osd_request *or;
  648. struct osd_attr attr;
  649. loff_t isize = i_size_read(inode);
  650. __be64 newsize;
  651. int ret;
  652. if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)
  653. || S_ISLNK(inode->i_mode)))
  654. return;
  655. if (exofs_inode_is_fast_symlink(inode))
  656. return;
  657. if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
  658. return;
  659. inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  660. nobh_truncate_page(inode->i_mapping, isize, exofs_get_block);
  661. or = osd_start_request(sbi->s_dev, GFP_KERNEL);
  662. if (unlikely(!or)) {
  663. EXOFS_ERR("ERROR: exofs_truncate: osd_start_request failed\n");
  664. goto fail;
  665. }
  666. osd_req_set_attributes(or, &obj);
  667. newsize = cpu_to_be64((u64)isize);
  668. attr = g_attr_logical_length;
  669. attr.val_ptr = &newsize;
  670. osd_req_add_set_attr_list(or, &attr, 1);
  671. /* if we are about to truncate an object, and it hasn't been
  672. * created yet, wait
  673. */
  674. if (unlikely(wait_obj_created(oi)))
  675. goto fail;
  676. ret = exofs_sync_op(or, sbi->s_timeout, oi->i_cred);
  677. osd_end_request(or);
  678. if (ret)
  679. goto fail;
  680. out:
  681. mark_inode_dirty(inode);
  682. return;
  683. fail:
  684. make_bad_inode(inode);
  685. goto out;
  686. }
  687. /*
  688. * Set inode attributes - just call generic functions.
  689. */
  690. int exofs_setattr(struct dentry *dentry, struct iattr *iattr)
  691. {
  692. struct inode *inode = dentry->d_inode;
  693. int error;
  694. error = inode_change_ok(inode, iattr);
  695. if (error)
  696. return error;
  697. error = inode_setattr(inode, iattr);
  698. return error;
  699. }
  700. /*
  701. * Read an inode from the OSD, and return it as is. We also return the size
  702. * attribute in the 'sanity' argument if we got compiled with debugging turned
  703. * on.
  704. */
  705. static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi,
  706. struct exofs_fcb *inode, uint64_t *sanity)
  707. {
  708. struct exofs_sb_info *sbi = sb->s_fs_info;
  709. struct osd_request *or;
  710. struct osd_attr attr;
  711. struct osd_obj_id obj = {sbi->s_pid,
  712. oi->vfs_inode.i_ino + EXOFS_OBJ_OFF};
  713. int ret;
  714. exofs_make_credential(oi->i_cred, &obj);
  715. or = osd_start_request(sbi->s_dev, GFP_KERNEL);
  716. if (unlikely(!or)) {
  717. EXOFS_ERR("exofs_get_inode: osd_start_request failed.\n");
  718. return -ENOMEM;
  719. }
  720. osd_req_get_attributes(or, &obj);
  721. /* we need the inode attribute */
  722. osd_req_add_get_attr_list(or, &g_attr_inode_data, 1);
  723. #ifdef EXOFS_DEBUG_OBJ_ISIZE
  724. /* we get the size attributes to do a sanity check */
  725. osd_req_add_get_attr_list(or, &g_attr_logical_length, 1);
  726. #endif
  727. ret = exofs_sync_op(or, sbi->s_timeout, oi->i_cred);
  728. if (ret)
  729. goto out;
  730. attr = g_attr_inode_data;
  731. ret = extract_attr_from_req(or, &attr);
  732. if (ret) {
  733. EXOFS_ERR("exofs_get_inode: extract_attr_from_req failed\n");
  734. goto out;
  735. }
  736. WARN_ON(attr.len != EXOFS_INO_ATTR_SIZE);
  737. memcpy(inode, attr.val_ptr, EXOFS_INO_ATTR_SIZE);
  738. #ifdef EXOFS_DEBUG_OBJ_ISIZE
  739. attr = g_attr_logical_length;
  740. ret = extract_attr_from_req(or, &attr);
  741. if (ret) {
  742. EXOFS_ERR("ERROR: extract attr from or failed\n");
  743. goto out;
  744. }
  745. *sanity = get_unaligned_be64(attr.val_ptr);
  746. #endif
  747. out:
  748. osd_end_request(or);
  749. return ret;
  750. }
  751. /*
  752. * Fill in an inode read from the OSD and set it up for use
  753. */
  754. struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
  755. {
  756. struct exofs_i_info *oi;
  757. struct exofs_fcb fcb;
  758. struct inode *inode;
  759. uint64_t uninitialized_var(sanity);
  760. int ret;
  761. inode = iget_locked(sb, ino);
  762. if (!inode)
  763. return ERR_PTR(-ENOMEM);
  764. if (!(inode->i_state & I_NEW))
  765. return inode;
  766. oi = exofs_i(inode);
  767. /* read the inode from the osd */
  768. ret = exofs_get_inode(sb, oi, &fcb, &sanity);
  769. if (ret)
  770. goto bad_inode;
  771. init_waitqueue_head(&oi->i_wq);
  772. set_obj_created(oi);
  773. /* copy stuff from on-disk struct to in-memory struct */
  774. inode->i_mode = le16_to_cpu(fcb.i_mode);
  775. inode->i_uid = le32_to_cpu(fcb.i_uid);
  776. inode->i_gid = le32_to_cpu(fcb.i_gid);
  777. inode->i_nlink = le16_to_cpu(fcb.i_links_count);
  778. inode->i_ctime.tv_sec = (signed)le32_to_cpu(fcb.i_ctime);
  779. inode->i_atime.tv_sec = (signed)le32_to_cpu(fcb.i_atime);
  780. inode->i_mtime.tv_sec = (signed)le32_to_cpu(fcb.i_mtime);
  781. inode->i_ctime.tv_nsec =
  782. inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = 0;
  783. oi->i_commit_size = le64_to_cpu(fcb.i_size);
  784. i_size_write(inode, oi->i_commit_size);
  785. inode->i_blkbits = EXOFS_BLKSHIFT;
  786. inode->i_generation = le32_to_cpu(fcb.i_generation);
  787. #ifdef EXOFS_DEBUG_OBJ_ISIZE
  788. if ((inode->i_size != sanity) &&
  789. (!exofs_inode_is_fast_symlink(inode))) {
  790. EXOFS_ERR("WARNING: Size of object from inode and "
  791. "attributes differ (%lld != %llu)\n",
  792. inode->i_size, _LLU(sanity));
  793. }
  794. #endif
  795. oi->i_dir_start_lookup = 0;
  796. if ((inode->i_nlink == 0) && (inode->i_mode == 0)) {
  797. ret = -ESTALE;
  798. goto bad_inode;
  799. }
  800. if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
  801. if (fcb.i_data[0])
  802. inode->i_rdev =
  803. old_decode_dev(le32_to_cpu(fcb.i_data[0]));
  804. else
  805. inode->i_rdev =
  806. new_decode_dev(le32_to_cpu(fcb.i_data[1]));
  807. } else {
  808. memcpy(oi->i_data, fcb.i_data, sizeof(fcb.i_data));
  809. }
  810. if (S_ISREG(inode->i_mode)) {
  811. inode->i_op = &exofs_file_inode_operations;
  812. inode->i_fop = &exofs_file_operations;
  813. inode->i_mapping->a_ops = &exofs_aops;
  814. } else if (S_ISDIR(inode->i_mode)) {
  815. inode->i_op = &exofs_dir_inode_operations;
  816. inode->i_fop = &exofs_dir_operations;
  817. inode->i_mapping->a_ops = &exofs_aops;
  818. } else if (S_ISLNK(inode->i_mode)) {
  819. if (exofs_inode_is_fast_symlink(inode))
  820. inode->i_op = &exofs_fast_symlink_inode_operations;
  821. else {
  822. inode->i_op = &exofs_symlink_inode_operations;
  823. inode->i_mapping->a_ops = &exofs_aops;
  824. }
  825. } else {
  826. inode->i_op = &exofs_special_inode_operations;
  827. if (fcb.i_data[0])
  828. init_special_inode(inode, inode->i_mode,
  829. old_decode_dev(le32_to_cpu(fcb.i_data[0])));
  830. else
  831. init_special_inode(inode, inode->i_mode,
  832. new_decode_dev(le32_to_cpu(fcb.i_data[1])));
  833. }
  834. unlock_new_inode(inode);
  835. return inode;
  836. bad_inode:
  837. iget_failed(inode);
  838. return ERR_PTR(ret);
  839. }
  840. int __exofs_wait_obj_created(struct exofs_i_info *oi)
  841. {
  842. if (!obj_created(oi)) {
  843. BUG_ON(!obj_2bcreated(oi));
  844. wait_event(oi->i_wq, obj_created(oi));
  845. }
  846. return unlikely(is_bad_inode(&oi->vfs_inode)) ? -EIO : 0;
  847. }
  848. /*
  849. * Callback function from exofs_new_inode(). The important thing is that we
  850. * set the obj_created flag so that other methods know that the object exists on
  851. * the OSD.
  852. */
  853. static void create_done(struct osd_request *or, void *p)
  854. {
  855. struct inode *inode = p;
  856. struct exofs_i_info *oi = exofs_i(inode);
  857. struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
  858. int ret;
  859. ret = exofs_check_ok(or);
  860. osd_end_request(or);
  861. atomic_dec(&sbi->s_curr_pending);
  862. if (unlikely(ret)) {
  863. EXOFS_ERR("object=0x%llx creation faild in pid=0x%llx",
  864. _LLU(sbi->s_pid), _LLU(inode->i_ino + EXOFS_OBJ_OFF));
  865. make_bad_inode(inode);
  866. } else
  867. set_obj_created(oi);
  868. atomic_dec(&inode->i_count);
  869. wake_up(&oi->i_wq);
  870. }
  871. /*
  872. * Set up a new inode and create an object for it on the OSD
  873. */
  874. struct inode *exofs_new_inode(struct inode *dir, int mode)
  875. {
  876. struct super_block *sb;
  877. struct inode *inode;
  878. struct exofs_i_info *oi;
  879. struct exofs_sb_info *sbi;
  880. struct osd_request *or;
  881. struct osd_obj_id obj;
  882. int ret;
  883. sb = dir->i_sb;
  884. inode = new_inode(sb);
  885. if (!inode)
  886. return ERR_PTR(-ENOMEM);
  887. oi = exofs_i(inode);
  888. init_waitqueue_head(&oi->i_wq);
  889. set_obj_2bcreated(oi);
  890. sbi = sb->s_fs_info;
  891. sb->s_dirt = 1;
  892. inode->i_uid = current->cred->fsuid;
  893. if (dir->i_mode & S_ISGID) {
  894. inode->i_gid = dir->i_gid;
  895. if (S_ISDIR(mode))
  896. mode |= S_ISGID;
  897. } else {
  898. inode->i_gid = current->cred->fsgid;
  899. }
  900. inode->i_mode = mode;
  901. inode->i_ino = sbi->s_nextid++;
  902. inode->i_blkbits = EXOFS_BLKSHIFT;
  903. inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
  904. oi->i_commit_size = inode->i_size = 0;
  905. spin_lock(&sbi->s_next_gen_lock);
  906. inode->i_generation = sbi->s_next_generation++;
  907. spin_unlock(&sbi->s_next_gen_lock);
  908. insert_inode_hash(inode);
  909. mark_inode_dirty(inode);
  910. obj.partition = sbi->s_pid;
  911. obj.id = inode->i_ino + EXOFS_OBJ_OFF;
  912. exofs_make_credential(oi->i_cred, &obj);
  913. or = osd_start_request(sbi->s_dev, GFP_KERNEL);
  914. if (unlikely(!or)) {
  915. EXOFS_ERR("exofs_new_inode: osd_start_request failed\n");
  916. return ERR_PTR(-ENOMEM);
  917. }
  918. osd_req_create_object(or, &obj);
  919. /* increment the refcount so that the inode will still be around when we
  920. * reach the callback
  921. */
  922. atomic_inc(&inode->i_count);
  923. ret = exofs_async_op(or, create_done, inode, oi->i_cred);
  924. if (ret) {
  925. atomic_dec(&inode->i_count);
  926. osd_end_request(or);
  927. return ERR_PTR(-EIO);
  928. }
  929. atomic_inc(&sbi->s_curr_pending);
  930. return inode;
  931. }
  932. /*
  933. * struct to pass two arguments to update_inode's callback
  934. */
  935. struct updatei_args {
  936. struct exofs_sb_info *sbi;
  937. struct exofs_fcb fcb;
  938. };
  939. /*
  940. * Callback function from exofs_update_inode().
  941. */
  942. static void updatei_done(struct osd_request *or, void *p)
  943. {
  944. struct updatei_args *args = p;
  945. osd_end_request(or);
  946. atomic_dec(&args->sbi->s_curr_pending);
  947. kfree(args);
  948. }
  949. /*
  950. * Write the inode to the OSD. Just fill up the struct, and set the attribute
  951. * synchronously or asynchronously depending on the do_sync flag.
  952. */
  953. static int exofs_update_inode(struct inode *inode, int do_sync)
  954. {
  955. struct exofs_i_info *oi = exofs_i(inode);
  956. struct super_block *sb = inode->i_sb;
  957. struct exofs_sb_info *sbi = sb->s_fs_info;
  958. struct osd_obj_id obj = {sbi->s_pid, inode->i_ino + EXOFS_OBJ_OFF};
  959. struct osd_request *or;
  960. struct osd_attr attr;
  961. struct exofs_fcb *fcb;
  962. struct updatei_args *args;
  963. int ret;
  964. args = kzalloc(sizeof(*args), GFP_KERNEL);
  965. if (!args)
  966. return -ENOMEM;
  967. fcb = &args->fcb;
  968. fcb->i_mode = cpu_to_le16(inode->i_mode);
  969. fcb->i_uid = cpu_to_le32(inode->i_uid);
  970. fcb->i_gid = cpu_to_le32(inode->i_gid);
  971. fcb->i_links_count = cpu_to_le16(inode->i_nlink);
  972. fcb->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
  973. fcb->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
  974. fcb->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
  975. oi->i_commit_size = i_size_read(inode);
  976. fcb->i_size = cpu_to_le64(oi->i_commit_size);
  977. fcb->i_generation = cpu_to_le32(inode->i_generation);
  978. if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
  979. if (old_valid_dev(inode->i_rdev)) {
  980. fcb->i_data[0] =
  981. cpu_to_le32(old_encode_dev(inode->i_rdev));
  982. fcb->i_data[1] = 0;
  983. } else {
  984. fcb->i_data[0] = 0;
  985. fcb->i_data[1] =
  986. cpu_to_le32(new_encode_dev(inode->i_rdev));
  987. fcb->i_data[2] = 0;
  988. }
  989. } else
  990. memcpy(fcb->i_data, oi->i_data, sizeof(fcb->i_data));
  991. or = osd_start_request(sbi->s_dev, GFP_KERNEL);
  992. if (unlikely(!or)) {
  993. EXOFS_ERR("exofs_update_inode: osd_start_request failed.\n");
  994. ret = -ENOMEM;
  995. goto free_args;
  996. }
  997. osd_req_set_attributes(or, &obj);
  998. attr = g_attr_inode_data;
  999. attr.val_ptr = fcb;
  1000. osd_req_add_set_attr_list(or, &attr, 1);
  1001. if (!obj_created(oi)) {
  1002. EXOFS_DBGMSG("!obj_created\n");
  1003. BUG_ON(!obj_2bcreated(oi));
  1004. wait_event(oi->i_wq, obj_created(oi));
  1005. EXOFS_DBGMSG("wait_event done\n");
  1006. }
  1007. if (do_sync) {
  1008. ret = exofs_sync_op(or, sbi->s_timeout, oi->i_cred);
  1009. osd_end_request(or);
  1010. goto free_args;
  1011. } else {
  1012. args->sbi = sbi;
  1013. ret = exofs_async_op(or, updatei_done, args, oi->i_cred);
  1014. if (ret) {
  1015. osd_end_request(or);
  1016. goto free_args;
  1017. }
  1018. atomic_inc(&sbi->s_curr_pending);
  1019. goto out; /* deallocation in updatei_done */
  1020. }
  1021. free_args:
  1022. kfree(args);
  1023. out:
  1024. EXOFS_DBGMSG("ret=>%d\n", ret);
  1025. return ret;
  1026. }
  1027. int exofs_write_inode(struct inode *inode, int wait)
  1028. {
  1029. return exofs_update_inode(inode, wait);
  1030. }
  1031. /*
  1032. * Callback function from exofs_delete_inode() - don't have much cleaning up to
  1033. * do.
  1034. */
  1035. static void delete_done(struct osd_request *or, void *p)
  1036. {
  1037. struct exofs_sb_info *sbi;
  1038. osd_end_request(or);
  1039. sbi = p;
  1040. atomic_dec(&sbi->s_curr_pending);
  1041. }
  1042. /*
  1043. * Called when the refcount of an inode reaches zero. We remove the object
  1044. * from the OSD here. We make sure the object was created before we try and
  1045. * delete it.
  1046. */
  1047. void exofs_delete_inode(struct inode *inode)
  1048. {
  1049. struct exofs_i_info *oi = exofs_i(inode);
  1050. struct super_block *sb = inode->i_sb;
  1051. struct exofs_sb_info *sbi = sb->s_fs_info;
  1052. struct osd_obj_id obj = {sbi->s_pid, inode->i_ino + EXOFS_OBJ_OFF};
  1053. struct osd_request *or;
  1054. int ret;
  1055. truncate_inode_pages(&inode->i_data, 0);
  1056. if (is_bad_inode(inode))
  1057. goto no_delete;
  1058. mark_inode_dirty(inode);
  1059. exofs_update_inode(inode, inode_needs_sync(inode));
  1060. inode->i_size = 0;
  1061. if (inode->i_blocks)
  1062. exofs_truncate(inode);
  1063. clear_inode(inode);
  1064. or = osd_start_request(sbi->s_dev, GFP_KERNEL);
  1065. if (unlikely(!or)) {
  1066. EXOFS_ERR("exofs_delete_inode: osd_start_request failed\n");
  1067. return;
  1068. }
  1069. osd_req_remove_object(or, &obj);
  1070. /* if we are deleting an obj that hasn't been created yet, wait */
  1071. if (!obj_created(oi)) {
  1072. BUG_ON(!obj_2bcreated(oi));
  1073. wait_event(oi->i_wq, obj_created(oi));
  1074. }
  1075. ret = exofs_async_op(or, delete_done, sbi, oi->i_cred);
  1076. if (ret) {
  1077. EXOFS_ERR(
  1078. "ERROR: @exofs_delete_inode exofs_async_op failed\n");
  1079. osd_end_request(or);
  1080. return;
  1081. }
  1082. atomic_inc(&sbi->s_curr_pending);
  1083. return;
  1084. no_delete:
  1085. clear_inode(inode);
  1086. }