inode.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  1. /*
  2. * Copyright (C) 2005, 2006
  3. * Avishay Traeger (avishay@gmail.com)
  4. * Copyright (C) 2008, 2009
  5. * Boaz Harrosh <bharrosh@panasas.com>
  6. *
  7. * Copyrights for code taken from ext2:
  8. * Copyright (C) 1992, 1993, 1994, 1995
  9. * Remy Card (card@masi.ibp.fr)
  10. * Laboratoire MASI - Institut Blaise Pascal
  11. * Universite Pierre et Marie Curie (Paris VI)
  12. * from
  13. * linux/fs/minix/inode.c
  14. * Copyright (C) 1991, 1992 Linus Torvalds
  15. *
  16. * This file is part of exofs.
  17. *
  18. * exofs is free software; you can redistribute it and/or modify
  19. * it under the terms of the GNU General Public License as published by
  20. * the Free Software Foundation. Since it is based on ext2, and the only
  21. * valid version of GPL for the Linux kernel is version 2, the only valid
  22. * version of GPL for exofs is version 2.
  23. *
  24. * exofs is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with exofs; if not, write to the Free Software
  31. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  32. */
  33. #include <linux/writeback.h>
  34. #include <linux/buffer_head.h>
  35. #include <scsi/scsi_device.h>
  36. #include "exofs.h"
  37. #ifdef CONFIG_EXOFS_DEBUG
  38. # define EXOFS_DEBUG_OBJ_ISIZE 1
  39. #endif
  40. struct page_collect {
  41. struct exofs_sb_info *sbi;
  42. struct request_queue *req_q;
  43. struct inode *inode;
  44. unsigned expected_pages;
  45. struct bio *bio;
  46. unsigned nr_pages;
  47. unsigned long length;
  48. loff_t pg_first; /* keep 64bit also in 32-arches */
  49. };
  50. static void _pcol_init(struct page_collect *pcol, unsigned expected_pages,
  51. struct inode *inode)
  52. {
  53. struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
  54. pcol->sbi = sbi;
  55. pcol->req_q = osd_request_queue(sbi->s_dev);
  56. pcol->inode = inode;
  57. pcol->expected_pages = expected_pages;
  58. pcol->bio = NULL;
  59. pcol->nr_pages = 0;
  60. pcol->length = 0;
  61. pcol->pg_first = -1;
  62. EXOFS_DBGMSG("_pcol_init ino=0x%lx expected_pages=%u\n", inode->i_ino,
  63. expected_pages);
  64. }
  65. static void _pcol_reset(struct page_collect *pcol)
  66. {
  67. pcol->expected_pages -= min(pcol->nr_pages, pcol->expected_pages);
  68. pcol->bio = NULL;
  69. pcol->nr_pages = 0;
  70. pcol->length = 0;
  71. pcol->pg_first = -1;
  72. EXOFS_DBGMSG("_pcol_reset ino=0x%lx expected_pages=%u\n",
  73. pcol->inode->i_ino, pcol->expected_pages);
  74. /* this is probably the end of the loop but in writes
  75. * it might not end here. don't be left with nothing
  76. */
  77. if (!pcol->expected_pages)
  78. pcol->expected_pages = 128;
  79. }
  80. static int pcol_try_alloc(struct page_collect *pcol)
  81. {
  82. int pages = min_t(unsigned, pcol->expected_pages, BIO_MAX_PAGES);
  83. for (; pages; pages >>= 1) {
  84. pcol->bio = bio_alloc(GFP_KERNEL, pages);
  85. if (likely(pcol->bio))
  86. return 0;
  87. }
  88. EXOFS_ERR("Failed to kcalloc expected_pages=%u\n",
  89. pcol->expected_pages);
  90. return -ENOMEM;
  91. }
  92. static void pcol_free(struct page_collect *pcol)
  93. {
  94. bio_put(pcol->bio);
  95. pcol->bio = NULL;
  96. }
  97. static int pcol_add_page(struct page_collect *pcol, struct page *page,
  98. unsigned len)
  99. {
  100. int added_len = bio_add_pc_page(pcol->req_q, pcol->bio, page, len, 0);
  101. if (unlikely(len != added_len))
  102. return -ENOMEM;
  103. ++pcol->nr_pages;
  104. pcol->length += len;
  105. return 0;
  106. }
  107. static int update_read_page(struct page *page, int ret)
  108. {
  109. if (ret == 0) {
  110. /* Everything is OK */
  111. SetPageUptodate(page);
  112. if (PageError(page))
  113. ClearPageError(page);
  114. } else if (ret == -EFAULT) {
  115. /* In this case we were trying to read something that wasn't on
  116. * disk yet - return a page full of zeroes. This should be OK,
  117. * because the object should be empty (if there was a write
  118. * before this read, the read would be waiting with the page
  119. * locked */
  120. clear_highpage(page);
  121. SetPageUptodate(page);
  122. if (PageError(page))
  123. ClearPageError(page);
  124. ret = 0; /* recovered error */
  125. EXOFS_DBGMSG("recovered read error\n");
  126. } else /* Error */
  127. SetPageError(page);
  128. return ret;
  129. }
  130. static void update_write_page(struct page *page, int ret)
  131. {
  132. if (ret) {
  133. mapping_set_error(page->mapping, ret);
  134. SetPageError(page);
  135. }
  136. end_page_writeback(page);
  137. }
  138. /* Called at the end of reads, to optionally unlock pages and update their
  139. * status.
  140. */
  141. static int __readpages_done(struct osd_request *or, struct page_collect *pcol,
  142. bool do_unlock)
  143. {
  144. struct bio_vec *bvec;
  145. int i;
  146. u64 resid;
  147. u64 good_bytes;
  148. u64 length = 0;
  149. int ret = exofs_check_ok_resid(or, &resid, NULL);
  150. osd_end_request(or);
  151. if (likely(!ret))
  152. good_bytes = pcol->length;
  153. else if (!resid)
  154. good_bytes = 0;
  155. else
  156. good_bytes = pcol->length - resid;
  157. EXOFS_DBGMSG("readpages_done(0x%lx) good_bytes=0x%llx"
  158. " length=0x%lx nr_pages=%u\n",
  159. pcol->inode->i_ino, _LLU(good_bytes), pcol->length,
  160. pcol->nr_pages);
  161. __bio_for_each_segment(bvec, pcol->bio, i, 0) {
  162. struct page *page = bvec->bv_page;
  163. struct inode *inode = page->mapping->host;
  164. int page_stat;
  165. if (inode != pcol->inode)
  166. continue; /* osd might add more pages at end */
  167. if (likely(length < good_bytes))
  168. page_stat = 0;
  169. else
  170. page_stat = ret;
  171. EXOFS_DBGMSG(" readpages_done(0x%lx, 0x%lx) %s\n",
  172. inode->i_ino, page->index,
  173. page_stat ? "bad_bytes" : "good_bytes");
  174. ret = update_read_page(page, page_stat);
  175. if (do_unlock)
  176. unlock_page(page);
  177. length += bvec->bv_len;
  178. }
  179. pcol_free(pcol);
  180. EXOFS_DBGMSG("readpages_done END\n");
  181. return ret;
  182. }
  183. /* callback of async reads */
  184. static void readpages_done(struct osd_request *or, void *p)
  185. {
  186. struct page_collect *pcol = p;
  187. __readpages_done(or, pcol, true);
  188. atomic_dec(&pcol->sbi->s_curr_pending);
  189. kfree(p);
  190. }
  191. static void _unlock_pcol_pages(struct page_collect *pcol, int ret, int rw)
  192. {
  193. struct bio_vec *bvec;
  194. int i;
  195. __bio_for_each_segment(bvec, pcol->bio, i, 0) {
  196. struct page *page = bvec->bv_page;
  197. if (rw == READ)
  198. update_read_page(page, ret);
  199. else
  200. update_write_page(page, ret);
  201. unlock_page(page);
  202. }
  203. pcol_free(pcol);
  204. }
  205. static int read_exec(struct page_collect *pcol, bool is_sync)
  206. {
  207. struct exofs_i_info *oi = exofs_i(pcol->inode);
  208. struct osd_obj_id obj = {pcol->sbi->s_pid,
  209. pcol->inode->i_ino + EXOFS_OBJ_OFF};
  210. struct osd_request *or = NULL;
  211. struct page_collect *pcol_copy = NULL;
  212. loff_t i_start = pcol->pg_first << PAGE_CACHE_SHIFT;
  213. int ret;
  214. if (!pcol->bio)
  215. return 0;
  216. /* see comment in _readpage() about sync reads */
  217. WARN_ON(is_sync && (pcol->nr_pages != 1));
  218. or = osd_start_request(pcol->sbi->s_dev, GFP_KERNEL);
  219. if (unlikely(!or)) {
  220. ret = -ENOMEM;
  221. goto err;
  222. }
  223. osd_req_read(or, &obj, i_start, pcol->bio, pcol->length);
  224. if (is_sync) {
  225. exofs_sync_op(or, pcol->sbi->s_timeout, oi->i_cred);
  226. return __readpages_done(or, pcol, false);
  227. }
  228. pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL);
  229. if (!pcol_copy) {
  230. ret = -ENOMEM;
  231. goto err;
  232. }
  233. *pcol_copy = *pcol;
  234. ret = exofs_async_op(or, readpages_done, pcol_copy, oi->i_cred);
  235. if (unlikely(ret))
  236. goto err;
  237. atomic_inc(&pcol->sbi->s_curr_pending);
  238. EXOFS_DBGMSG("read_exec obj=0x%llx start=0x%llx length=0x%lx\n",
  239. obj.id, _LLU(i_start), pcol->length);
  240. /* pages ownership was passed to pcol_copy */
  241. _pcol_reset(pcol);
  242. return 0;
  243. err:
  244. if (!is_sync)
  245. _unlock_pcol_pages(pcol, ret, READ);
  246. else /* Pages unlocked by caller in sync mode only free bio */
  247. pcol_free(pcol);
  248. kfree(pcol_copy);
  249. if (or)
  250. osd_end_request(or);
  251. return ret;
  252. }
  253. /* readpage_strip is called either directly from readpage() or by the VFS from
  254. * within read_cache_pages(), to add one more page to be read. It will try to
  255. * collect as many contiguous pages as posible. If a discontinuity is
  256. * encountered, or it runs out of resources, it will submit the previous segment
  257. * and will start a new collection. Eventually caller must submit the last
  258. * segment if present.
  259. */
  260. static int readpage_strip(void *data, struct page *page)
  261. {
  262. struct page_collect *pcol = data;
  263. struct inode *inode = pcol->inode;
  264. struct exofs_i_info *oi = exofs_i(inode);
  265. loff_t i_size = i_size_read(inode);
  266. pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
  267. size_t len;
  268. int ret;
  269. /* FIXME: Just for debugging, will be removed */
  270. if (PageUptodate(page))
  271. EXOFS_ERR("PageUptodate(0x%lx, 0x%lx)\n", pcol->inode->i_ino,
  272. page->index);
  273. if (page->index < end_index)
  274. len = PAGE_CACHE_SIZE;
  275. else if (page->index == end_index)
  276. len = i_size & ~PAGE_CACHE_MASK;
  277. else
  278. len = 0;
  279. if (!len || !obj_created(oi)) {
  280. /* this will be out of bounds, or doesn't exist yet.
  281. * Current page is cleared and the request is split
  282. */
  283. clear_highpage(page);
  284. SetPageUptodate(page);
  285. if (PageError(page))
  286. ClearPageError(page);
  287. unlock_page(page);
  288. EXOFS_DBGMSG("readpage_strip(0x%lx, 0x%lx) empty page,"
  289. " splitting\n", inode->i_ino, page->index);
  290. return read_exec(pcol, false);
  291. }
  292. try_again:
  293. if (unlikely(pcol->pg_first == -1)) {
  294. pcol->pg_first = page->index;
  295. } else if (unlikely((pcol->pg_first + pcol->nr_pages) !=
  296. page->index)) {
  297. /* Discontinuity detected, split the request */
  298. ret = read_exec(pcol, false);
  299. if (unlikely(ret))
  300. goto fail;
  301. goto try_again;
  302. }
  303. if (!pcol->bio) {
  304. ret = pcol_try_alloc(pcol);
  305. if (unlikely(ret))
  306. goto fail;
  307. }
  308. if (len != PAGE_CACHE_SIZE)
  309. zero_user(page, len, PAGE_CACHE_SIZE - len);
  310. EXOFS_DBGMSG(" readpage_strip(0x%lx, 0x%lx) len=0x%zx\n",
  311. inode->i_ino, page->index, len);
  312. ret = pcol_add_page(pcol, page, len);
  313. if (ret) {
  314. EXOFS_DBGMSG("Failed pcol_add_page pages[i]=%p "
  315. "this_len=0x%zx nr_pages=%u length=0x%lx\n",
  316. page, len, pcol->nr_pages, pcol->length);
  317. /* split the request, and start again with current page */
  318. ret = read_exec(pcol, false);
  319. if (unlikely(ret))
  320. goto fail;
  321. goto try_again;
  322. }
  323. return 0;
  324. fail:
  325. /* SetPageError(page); ??? */
  326. unlock_page(page);
  327. return ret;
  328. }
  329. static int exofs_readpages(struct file *file, struct address_space *mapping,
  330. struct list_head *pages, unsigned nr_pages)
  331. {
  332. struct page_collect pcol;
  333. int ret;
  334. _pcol_init(&pcol, nr_pages, mapping->host);
  335. ret = read_cache_pages(mapping, pages, readpage_strip, &pcol);
  336. if (ret) {
  337. EXOFS_ERR("read_cache_pages => %d\n", ret);
  338. return ret;
  339. }
  340. return read_exec(&pcol, false);
  341. }
  342. static int _readpage(struct page *page, bool is_sync)
  343. {
  344. struct page_collect pcol;
  345. int ret;
  346. _pcol_init(&pcol, 1, page->mapping->host);
  347. /* readpage_strip might call read_exec(,async) inside at several places
  348. * but this is safe for is_async=0 since read_exec will not do anything
  349. * when we have a single page.
  350. */
  351. ret = readpage_strip(&pcol, page);
  352. if (ret) {
  353. EXOFS_ERR("_readpage => %d\n", ret);
  354. return ret;
  355. }
  356. return read_exec(&pcol, is_sync);
  357. }
  358. /*
  359. * We don't need the file
  360. */
  361. static int exofs_readpage(struct file *file, struct page *page)
  362. {
  363. return _readpage(page, false);
  364. }
  365. /* Callback for osd_write. All writes are asynchronouse */
  366. static void writepages_done(struct osd_request *or, void *p)
  367. {
  368. struct page_collect *pcol = p;
  369. struct bio_vec *bvec;
  370. int i;
  371. u64 resid;
  372. u64 good_bytes;
  373. u64 length = 0;
  374. int ret = exofs_check_ok_resid(or, NULL, &resid);
  375. osd_end_request(or);
  376. atomic_dec(&pcol->sbi->s_curr_pending);
  377. if (likely(!ret))
  378. good_bytes = pcol->length;
  379. else if (!resid)
  380. good_bytes = 0;
  381. else
  382. good_bytes = pcol->length - resid;
  383. EXOFS_DBGMSG("writepages_done(0x%lx) good_bytes=0x%llx"
  384. " length=0x%lx nr_pages=%u\n",
  385. pcol->inode->i_ino, _LLU(good_bytes), pcol->length,
  386. pcol->nr_pages);
  387. __bio_for_each_segment(bvec, pcol->bio, i, 0) {
  388. struct page *page = bvec->bv_page;
  389. struct inode *inode = page->mapping->host;
  390. int page_stat;
  391. if (inode != pcol->inode)
  392. continue; /* osd might add more pages to a bio */
  393. if (likely(length < good_bytes))
  394. page_stat = 0;
  395. else
  396. page_stat = ret;
  397. update_write_page(page, page_stat);
  398. unlock_page(page);
  399. EXOFS_DBGMSG(" writepages_done(0x%lx, 0x%lx) status=%d\n",
  400. inode->i_ino, page->index, page_stat);
  401. length += bvec->bv_len;
  402. }
  403. pcol_free(pcol);
  404. kfree(pcol);
  405. EXOFS_DBGMSG("writepages_done END\n");
  406. }
  407. static int write_exec(struct page_collect *pcol)
  408. {
  409. struct exofs_i_info *oi = exofs_i(pcol->inode);
  410. struct osd_obj_id obj = {pcol->sbi->s_pid,
  411. pcol->inode->i_ino + EXOFS_OBJ_OFF};
  412. struct osd_request *or = NULL;
  413. struct page_collect *pcol_copy = NULL;
  414. loff_t i_start = pcol->pg_first << PAGE_CACHE_SHIFT;
  415. int ret;
  416. if (!pcol->bio)
  417. return 0;
  418. or = osd_start_request(pcol->sbi->s_dev, GFP_KERNEL);
  419. if (unlikely(!or)) {
  420. EXOFS_ERR("write_exec: Faild to osd_start_request()\n");
  421. ret = -ENOMEM;
  422. goto err;
  423. }
  424. pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL);
  425. if (!pcol_copy) {
  426. EXOFS_ERR("write_exec: Faild to kmalloc(pcol)\n");
  427. ret = -ENOMEM;
  428. goto err;
  429. }
  430. *pcol_copy = *pcol;
  431. pcol_copy->bio->bi_rw |= (1 << BIO_RW); /* FIXME: bio_set_dir() */
  432. osd_req_write(or, &obj, i_start, pcol_copy->bio, pcol_copy->length);
  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. }