fs-writeback.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314
  1. /*
  2. * fs/fs-writeback.c
  3. *
  4. * Copyright (C) 2002, Linus Torvalds.
  5. *
  6. * Contains all the functions related to writing back and waiting
  7. * upon dirty inodes against superblocks, and writing back dirty
  8. * pages against inodes. ie: data writeback. Writeout of the
  9. * inode itself is not handled here.
  10. *
  11. * 10Apr2002 Andrew Morton
  12. * Split out of fs/inode.c
  13. * Additions for address_space-based writeback
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/module.h>
  17. #include <linux/spinlock.h>
  18. #include <linux/slab.h>
  19. #include <linux/sched.h>
  20. #include <linux/fs.h>
  21. #include <linux/mm.h>
  22. #include <linux/kthread.h>
  23. #include <linux/freezer.h>
  24. #include <linux/writeback.h>
  25. #include <linux/blkdev.h>
  26. #include <linux/backing-dev.h>
  27. #include <linux/buffer_head.h>
  28. #include "internal.h"
  29. #define inode_to_bdi(inode) ((inode)->i_mapping->backing_dev_info)
  30. /*
  31. * We don't actually have pdflush, but this one is exported though /proc...
  32. */
  33. int nr_pdflush_threads;
  34. /*
  35. * Passed into wb_writeback(), essentially a subset of writeback_control
  36. */
  37. struct wb_writeback_args {
  38. long nr_pages;
  39. struct super_block *sb;
  40. enum writeback_sync_modes sync_mode;
  41. unsigned int for_kupdate:1;
  42. unsigned int range_cyclic:1;
  43. unsigned int for_background:1;
  44. };
  45. /*
  46. * Work items for the bdi_writeback threads
  47. */
  48. struct bdi_work {
  49. struct list_head list; /* pending work list */
  50. struct rcu_head rcu_head; /* for RCU free/clear of work */
  51. unsigned long seen; /* threads that have seen this work */
  52. atomic_t pending; /* number of threads still to do work */
  53. struct wb_writeback_args args; /* writeback arguments */
  54. unsigned long state; /* flag bits, see WS_* */
  55. };
  56. enum {
  57. WS_USED_B = 0,
  58. WS_ONSTACK_B,
  59. };
  60. #define WS_USED (1 << WS_USED_B)
  61. #define WS_ONSTACK (1 << WS_ONSTACK_B)
  62. static inline bool bdi_work_on_stack(struct bdi_work *work)
  63. {
  64. return test_bit(WS_ONSTACK_B, &work->state);
  65. }
  66. static inline void bdi_work_init(struct bdi_work *work,
  67. struct wb_writeback_args *args)
  68. {
  69. INIT_RCU_HEAD(&work->rcu_head);
  70. work->args = *args;
  71. work->state = WS_USED;
  72. }
  73. /**
  74. * writeback_in_progress - determine whether there is writeback in progress
  75. * @bdi: the device's backing_dev_info structure.
  76. *
  77. * Determine whether there is writeback waiting to be handled against a
  78. * backing device.
  79. */
  80. int writeback_in_progress(struct backing_dev_info *bdi)
  81. {
  82. return !list_empty(&bdi->work_list);
  83. }
  84. static void bdi_work_clear(struct bdi_work *work)
  85. {
  86. clear_bit(WS_USED_B, &work->state);
  87. smp_mb__after_clear_bit();
  88. /*
  89. * work can have disappeared at this point. bit waitq functions
  90. * should be able to tolerate this, provided bdi_sched_wait does
  91. * not dereference it's pointer argument.
  92. */
  93. wake_up_bit(&work->state, WS_USED_B);
  94. }
  95. static void bdi_work_free(struct rcu_head *head)
  96. {
  97. struct bdi_work *work = container_of(head, struct bdi_work, rcu_head);
  98. if (!bdi_work_on_stack(work))
  99. kfree(work);
  100. else
  101. bdi_work_clear(work);
  102. }
  103. static void wb_work_complete(struct bdi_work *work)
  104. {
  105. const enum writeback_sync_modes sync_mode = work->args.sync_mode;
  106. int onstack = bdi_work_on_stack(work);
  107. /*
  108. * For allocated work, we can clear the done/seen bit right here.
  109. * For on-stack work, we need to postpone both the clear and free
  110. * to after the RCU grace period, since the stack could be invalidated
  111. * as soon as bdi_work_clear() has done the wakeup.
  112. */
  113. if (!onstack)
  114. bdi_work_clear(work);
  115. if (sync_mode == WB_SYNC_NONE || onstack)
  116. call_rcu(&work->rcu_head, bdi_work_free);
  117. }
  118. static void wb_clear_pending(struct bdi_writeback *wb, struct bdi_work *work)
  119. {
  120. /*
  121. * The caller has retrieved the work arguments from this work,
  122. * drop our reference. If this is the last ref, delete and free it
  123. */
  124. if (atomic_dec_and_test(&work->pending)) {
  125. struct backing_dev_info *bdi = wb->bdi;
  126. spin_lock(&bdi->wb_lock);
  127. list_del_rcu(&work->list);
  128. spin_unlock(&bdi->wb_lock);
  129. wb_work_complete(work);
  130. }
  131. }
  132. static void bdi_queue_work(struct backing_dev_info *bdi, struct bdi_work *work)
  133. {
  134. work->seen = bdi->wb_mask;
  135. BUG_ON(!work->seen);
  136. atomic_set(&work->pending, bdi->wb_cnt);
  137. BUG_ON(!bdi->wb_cnt);
  138. /*
  139. * list_add_tail_rcu() contains the necessary barriers to
  140. * make sure the above stores are seen before the item is
  141. * noticed on the list
  142. */
  143. spin_lock(&bdi->wb_lock);
  144. list_add_tail_rcu(&work->list, &bdi->work_list);
  145. spin_unlock(&bdi->wb_lock);
  146. /*
  147. * If the default thread isn't there, make sure we add it. When
  148. * it gets created and wakes up, we'll run this work.
  149. */
  150. if (unlikely(list_empty_careful(&bdi->wb_list)))
  151. wake_up_process(default_backing_dev_info.wb.task);
  152. else {
  153. struct bdi_writeback *wb = &bdi->wb;
  154. if (wb->task)
  155. wake_up_process(wb->task);
  156. }
  157. }
  158. /*
  159. * Used for on-stack allocated work items. The caller needs to wait until
  160. * the wb threads have acked the work before it's safe to continue.
  161. */
  162. static void bdi_wait_on_work_clear(struct bdi_work *work)
  163. {
  164. wait_on_bit(&work->state, WS_USED_B, bdi_sched_wait,
  165. TASK_UNINTERRUPTIBLE);
  166. }
  167. static void bdi_alloc_queue_work(struct backing_dev_info *bdi,
  168. struct wb_writeback_args *args)
  169. {
  170. struct bdi_work *work;
  171. /*
  172. * This is WB_SYNC_NONE writeback, so if allocation fails just
  173. * wakeup the thread for old dirty data writeback
  174. */
  175. work = kmalloc(sizeof(*work), GFP_ATOMIC);
  176. if (work) {
  177. bdi_work_init(work, args);
  178. bdi_queue_work(bdi, work);
  179. } else {
  180. struct bdi_writeback *wb = &bdi->wb;
  181. if (wb->task)
  182. wake_up_process(wb->task);
  183. }
  184. }
  185. /**
  186. * bdi_sync_writeback - start and wait for writeback
  187. * @bdi: the backing device to write from
  188. * @sb: write inodes from this super_block
  189. *
  190. * Description:
  191. * This does WB_SYNC_ALL data integrity writeback and waits for the
  192. * IO to complete. Callers must hold the sb s_umount semaphore for
  193. * reading, to avoid having the super disappear before we are done.
  194. */
  195. static void bdi_sync_writeback(struct backing_dev_info *bdi,
  196. struct super_block *sb)
  197. {
  198. struct wb_writeback_args args = {
  199. .sb = sb,
  200. .sync_mode = WB_SYNC_ALL,
  201. .nr_pages = LONG_MAX,
  202. .range_cyclic = 0,
  203. };
  204. struct bdi_work work;
  205. bdi_work_init(&work, &args);
  206. work.state |= WS_ONSTACK;
  207. bdi_queue_work(bdi, &work);
  208. bdi_wait_on_work_clear(&work);
  209. }
  210. /**
  211. * bdi_start_writeback - start writeback
  212. * @bdi: the backing device to write from
  213. * @sb: write inodes from this super_block
  214. * @nr_pages: the number of pages to write
  215. *
  216. * Description:
  217. * This does WB_SYNC_NONE opportunistic writeback. The IO is only
  218. * started when this function returns, we make no guarentees on
  219. * completion. Caller need not hold sb s_umount semaphore.
  220. *
  221. */
  222. void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb,
  223. long nr_pages)
  224. {
  225. struct wb_writeback_args args = {
  226. .sb = sb,
  227. .sync_mode = WB_SYNC_NONE,
  228. .nr_pages = nr_pages,
  229. .range_cyclic = 1,
  230. };
  231. /*
  232. * We treat @nr_pages=0 as the special case to do background writeback,
  233. * ie. to sync pages until the background dirty threshold is reached.
  234. */
  235. if (!nr_pages) {
  236. args.nr_pages = LONG_MAX;
  237. args.for_background = 1;
  238. }
  239. bdi_alloc_queue_work(bdi, &args);
  240. }
  241. /*
  242. * Redirty an inode: set its when-it-was dirtied timestamp and move it to the
  243. * furthest end of its superblock's dirty-inode list.
  244. *
  245. * Before stamping the inode's ->dirtied_when, we check to see whether it is
  246. * already the most-recently-dirtied inode on the b_dirty list. If that is
  247. * the case then the inode must have been redirtied while it was being written
  248. * out and we don't reset its dirtied_when.
  249. */
  250. static void redirty_tail(struct inode *inode)
  251. {
  252. struct bdi_writeback *wb = &inode_to_bdi(inode)->wb;
  253. if (!list_empty(&wb->b_dirty)) {
  254. struct inode *tail;
  255. tail = list_entry(wb->b_dirty.next, struct inode, i_list);
  256. if (time_before(inode->dirtied_when, tail->dirtied_when))
  257. inode->dirtied_when = jiffies;
  258. }
  259. list_move(&inode->i_list, &wb->b_dirty);
  260. }
  261. /*
  262. * requeue inode for re-scanning after bdi->b_io list is exhausted.
  263. */
  264. static void requeue_io(struct inode *inode)
  265. {
  266. struct bdi_writeback *wb = &inode_to_bdi(inode)->wb;
  267. list_move(&inode->i_list, &wb->b_more_io);
  268. }
  269. static void inode_sync_complete(struct inode *inode)
  270. {
  271. /*
  272. * Prevent speculative execution through spin_unlock(&inode_lock);
  273. */
  274. smp_mb();
  275. wake_up_bit(&inode->i_state, __I_SYNC);
  276. }
  277. static bool inode_dirtied_after(struct inode *inode, unsigned long t)
  278. {
  279. bool ret = time_after(inode->dirtied_when, t);
  280. #ifndef CONFIG_64BIT
  281. /*
  282. * For inodes being constantly redirtied, dirtied_when can get stuck.
  283. * It _appears_ to be in the future, but is actually in distant past.
  284. * This test is necessary to prevent such wrapped-around relative times
  285. * from permanently stopping the whole bdi writeback.
  286. */
  287. ret = ret && time_before_eq(inode->dirtied_when, jiffies);
  288. #endif
  289. return ret;
  290. }
  291. /*
  292. * Move expired dirty inodes from @delaying_queue to @dispatch_queue.
  293. */
  294. static void move_expired_inodes(struct list_head *delaying_queue,
  295. struct list_head *dispatch_queue,
  296. unsigned long *older_than_this)
  297. {
  298. LIST_HEAD(tmp);
  299. struct list_head *pos, *node;
  300. struct super_block *sb = NULL;
  301. struct inode *inode;
  302. int do_sb_sort = 0;
  303. while (!list_empty(delaying_queue)) {
  304. inode = list_entry(delaying_queue->prev, struct inode, i_list);
  305. if (older_than_this &&
  306. inode_dirtied_after(inode, *older_than_this))
  307. break;
  308. if (sb && sb != inode->i_sb)
  309. do_sb_sort = 1;
  310. sb = inode->i_sb;
  311. list_move(&inode->i_list, &tmp);
  312. }
  313. /* just one sb in list, splice to dispatch_queue and we're done */
  314. if (!do_sb_sort) {
  315. list_splice(&tmp, dispatch_queue);
  316. return;
  317. }
  318. /* Move inodes from one superblock together */
  319. while (!list_empty(&tmp)) {
  320. inode = list_entry(tmp.prev, struct inode, i_list);
  321. sb = inode->i_sb;
  322. list_for_each_prev_safe(pos, node, &tmp) {
  323. inode = list_entry(pos, struct inode, i_list);
  324. if (inode->i_sb == sb)
  325. list_move(&inode->i_list, dispatch_queue);
  326. }
  327. }
  328. }
  329. /*
  330. * Queue all expired dirty inodes for io, eldest first.
  331. */
  332. static void queue_io(struct bdi_writeback *wb, unsigned long *older_than_this)
  333. {
  334. list_splice_init(&wb->b_more_io, wb->b_io.prev);
  335. move_expired_inodes(&wb->b_dirty, &wb->b_io, older_than_this);
  336. }
  337. static int write_inode(struct inode *inode, struct writeback_control *wbc)
  338. {
  339. if (inode->i_sb->s_op->write_inode && !is_bad_inode(inode))
  340. return inode->i_sb->s_op->write_inode(inode, wbc);
  341. return 0;
  342. }
  343. /*
  344. * Wait for writeback on an inode to complete.
  345. */
  346. static void inode_wait_for_writeback(struct inode *inode)
  347. {
  348. DEFINE_WAIT_BIT(wq, &inode->i_state, __I_SYNC);
  349. wait_queue_head_t *wqh;
  350. wqh = bit_waitqueue(&inode->i_state, __I_SYNC);
  351. while (inode->i_state & I_SYNC) {
  352. spin_unlock(&inode_lock);
  353. __wait_on_bit(wqh, &wq, inode_wait, TASK_UNINTERRUPTIBLE);
  354. spin_lock(&inode_lock);
  355. }
  356. }
  357. /*
  358. * Write out an inode's dirty pages. Called under inode_lock. Either the
  359. * caller has ref on the inode (either via __iget or via syscall against an fd)
  360. * or the inode has I_WILL_FREE set (via generic_forget_inode)
  361. *
  362. * If `wait' is set, wait on the writeout.
  363. *
  364. * The whole writeout design is quite complex and fragile. We want to avoid
  365. * starvation of particular inodes when others are being redirtied, prevent
  366. * livelocks, etc.
  367. *
  368. * Called under inode_lock.
  369. */
  370. static int
  371. writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
  372. {
  373. struct address_space *mapping = inode->i_mapping;
  374. unsigned dirty;
  375. int ret;
  376. if (!atomic_read(&inode->i_count))
  377. WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING)));
  378. else
  379. WARN_ON(inode->i_state & I_WILL_FREE);
  380. if (inode->i_state & I_SYNC) {
  381. /*
  382. * If this inode is locked for writeback and we are not doing
  383. * writeback-for-data-integrity, move it to b_more_io so that
  384. * writeback can proceed with the other inodes on s_io.
  385. *
  386. * We'll have another go at writing back this inode when we
  387. * completed a full scan of b_io.
  388. */
  389. if (wbc->sync_mode != WB_SYNC_ALL) {
  390. requeue_io(inode);
  391. return 0;
  392. }
  393. /*
  394. * It's a data-integrity sync. We must wait.
  395. */
  396. inode_wait_for_writeback(inode);
  397. }
  398. BUG_ON(inode->i_state & I_SYNC);
  399. /* Set I_SYNC, reset I_DIRTY_PAGES */
  400. inode->i_state |= I_SYNC;
  401. inode->i_state &= ~I_DIRTY_PAGES;
  402. spin_unlock(&inode_lock);
  403. ret = do_writepages(mapping, wbc);
  404. /*
  405. * Make sure to wait on the data before writing out the metadata.
  406. * This is important for filesystems that modify metadata on data
  407. * I/O completion.
  408. */
  409. if (wbc->sync_mode == WB_SYNC_ALL) {
  410. int err = filemap_fdatawait(mapping);
  411. if (ret == 0)
  412. ret = err;
  413. }
  414. /*
  415. * Some filesystems may redirty the inode during the writeback
  416. * due to delalloc, clear dirty metadata flags right before
  417. * write_inode()
  418. */
  419. spin_lock(&inode_lock);
  420. dirty = inode->i_state & I_DIRTY;
  421. inode->i_state &= ~(I_DIRTY_SYNC | I_DIRTY_DATASYNC);
  422. spin_unlock(&inode_lock);
  423. /* Don't write the inode if only I_DIRTY_PAGES was set */
  424. if (dirty & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) {
  425. int err = write_inode(inode, wbc);
  426. if (ret == 0)
  427. ret = err;
  428. }
  429. spin_lock(&inode_lock);
  430. inode->i_state &= ~I_SYNC;
  431. if (!(inode->i_state & (I_FREEING | I_CLEAR))) {
  432. if ((inode->i_state & I_DIRTY_PAGES) && wbc->for_kupdate) {
  433. /*
  434. * More pages get dirtied by a fast dirtier.
  435. */
  436. goto select_queue;
  437. } else if (inode->i_state & I_DIRTY) {
  438. /*
  439. * At least XFS will redirty the inode during the
  440. * writeback (delalloc) and on io completion (isize).
  441. */
  442. redirty_tail(inode);
  443. } else if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
  444. /*
  445. * We didn't write back all the pages. nfs_writepages()
  446. * sometimes bales out without doing anything. Redirty
  447. * the inode; Move it from b_io onto b_more_io/b_dirty.
  448. */
  449. /*
  450. * akpm: if the caller was the kupdate function we put
  451. * this inode at the head of b_dirty so it gets first
  452. * consideration. Otherwise, move it to the tail, for
  453. * the reasons described there. I'm not really sure
  454. * how much sense this makes. Presumably I had a good
  455. * reasons for doing it this way, and I'd rather not
  456. * muck with it at present.
  457. */
  458. if (wbc->for_kupdate) {
  459. /*
  460. * For the kupdate function we move the inode
  461. * to b_more_io so it will get more writeout as
  462. * soon as the queue becomes uncongested.
  463. */
  464. inode->i_state |= I_DIRTY_PAGES;
  465. select_queue:
  466. if (wbc->nr_to_write <= 0) {
  467. /*
  468. * slice used up: queue for next turn
  469. */
  470. requeue_io(inode);
  471. } else {
  472. /*
  473. * somehow blocked: retry later
  474. */
  475. redirty_tail(inode);
  476. }
  477. } else {
  478. /*
  479. * Otherwise fully redirty the inode so that
  480. * other inodes on this superblock will get some
  481. * writeout. Otherwise heavy writing to one
  482. * file would indefinitely suspend writeout of
  483. * all the other files.
  484. */
  485. inode->i_state |= I_DIRTY_PAGES;
  486. redirty_tail(inode);
  487. }
  488. } else if (atomic_read(&inode->i_count)) {
  489. /*
  490. * The inode is clean, inuse
  491. */
  492. list_move(&inode->i_list, &inode_in_use);
  493. } else {
  494. /*
  495. * The inode is clean, unused
  496. */
  497. list_move(&inode->i_list, &inode_unused);
  498. }
  499. }
  500. inode_sync_complete(inode);
  501. return ret;
  502. }
  503. static void unpin_sb_for_writeback(struct super_block *sb)
  504. {
  505. up_read(&sb->s_umount);
  506. put_super(sb);
  507. }
  508. enum sb_pin_state {
  509. SB_PINNED,
  510. SB_NOT_PINNED,
  511. SB_PIN_FAILED
  512. };
  513. /*
  514. * For WB_SYNC_NONE writeback, the caller does not have the sb pinned
  515. * before calling writeback. So make sure that we do pin it, so it doesn't
  516. * go away while we are writing inodes from it.
  517. */
  518. static enum sb_pin_state pin_sb_for_writeback(struct writeback_control *wbc,
  519. struct super_block *sb)
  520. {
  521. /*
  522. * Caller must already hold the ref for this
  523. */
  524. if (wbc->sync_mode == WB_SYNC_ALL) {
  525. WARN_ON(!rwsem_is_locked(&sb->s_umount));
  526. return SB_NOT_PINNED;
  527. }
  528. spin_lock(&sb_lock);
  529. sb->s_count++;
  530. if (down_read_trylock(&sb->s_umount)) {
  531. if (sb->s_root) {
  532. spin_unlock(&sb_lock);
  533. return SB_PINNED;
  534. }
  535. /*
  536. * umounted, drop rwsem again and fall through to failure
  537. */
  538. up_read(&sb->s_umount);
  539. }
  540. sb->s_count--;
  541. spin_unlock(&sb_lock);
  542. return SB_PIN_FAILED;
  543. }
  544. /*
  545. * Write a portion of b_io inodes which belong to @sb.
  546. * If @wbc->sb != NULL, then find and write all such
  547. * inodes. Otherwise write only ones which go sequentially
  548. * in reverse order.
  549. * Return 1, if the caller writeback routine should be
  550. * interrupted. Otherwise return 0.
  551. */
  552. static int writeback_sb_inodes(struct super_block *sb,
  553. struct bdi_writeback *wb,
  554. struct writeback_control *wbc)
  555. {
  556. while (!list_empty(&wb->b_io)) {
  557. long pages_skipped;
  558. struct inode *inode = list_entry(wb->b_io.prev,
  559. struct inode, i_list);
  560. if (wbc->sb && sb != inode->i_sb) {
  561. /* super block given and doesn't
  562. match, skip this inode */
  563. redirty_tail(inode);
  564. continue;
  565. }
  566. if (sb != inode->i_sb)
  567. /* finish with this superblock */
  568. return 0;
  569. if (inode->i_state & (I_NEW | I_WILL_FREE)) {
  570. requeue_io(inode);
  571. continue;
  572. }
  573. /*
  574. * Was this inode dirtied after sync_sb_inodes was called?
  575. * This keeps sync from extra jobs and livelock.
  576. */
  577. if (inode_dirtied_after(inode, wbc->wb_start))
  578. return 1;
  579. BUG_ON(inode->i_state & (I_FREEING | I_CLEAR));
  580. __iget(inode);
  581. pages_skipped = wbc->pages_skipped;
  582. writeback_single_inode(inode, wbc);
  583. if (wbc->pages_skipped != pages_skipped) {
  584. /*
  585. * writeback is not making progress due to locked
  586. * buffers. Skip this inode for now.
  587. */
  588. redirty_tail(inode);
  589. }
  590. spin_unlock(&inode_lock);
  591. iput(inode);
  592. cond_resched();
  593. spin_lock(&inode_lock);
  594. if (wbc->nr_to_write <= 0) {
  595. wbc->more_io = 1;
  596. return 1;
  597. }
  598. if (!list_empty(&wb->b_more_io))
  599. wbc->more_io = 1;
  600. }
  601. /* b_io is empty */
  602. return 1;
  603. }
  604. static void writeback_inodes_wb(struct bdi_writeback *wb,
  605. struct writeback_control *wbc)
  606. {
  607. int ret = 0;
  608. wbc->wb_start = jiffies; /* livelock avoidance */
  609. spin_lock(&inode_lock);
  610. if (!wbc->for_kupdate || list_empty(&wb->b_io))
  611. queue_io(wb, wbc->older_than_this);
  612. while (!list_empty(&wb->b_io)) {
  613. struct inode *inode = list_entry(wb->b_io.prev,
  614. struct inode, i_list);
  615. struct super_block *sb = inode->i_sb;
  616. enum sb_pin_state state;
  617. if (wbc->sb && sb != wbc->sb) {
  618. /* super block given and doesn't
  619. match, skip this inode */
  620. redirty_tail(inode);
  621. continue;
  622. }
  623. state = pin_sb_for_writeback(wbc, sb);
  624. if (state == SB_PIN_FAILED) {
  625. requeue_io(inode);
  626. continue;
  627. }
  628. ret = writeback_sb_inodes(sb, wb, wbc);
  629. if (state == SB_PINNED)
  630. unpin_sb_for_writeback(sb);
  631. if (ret)
  632. break;
  633. }
  634. spin_unlock(&inode_lock);
  635. /* Leave any unwritten inodes on b_io */
  636. }
  637. void writeback_inodes_wbc(struct writeback_control *wbc)
  638. {
  639. struct backing_dev_info *bdi = wbc->bdi;
  640. writeback_inodes_wb(&bdi->wb, wbc);
  641. }
  642. /*
  643. * The maximum number of pages to writeout in a single bdi flush/kupdate
  644. * operation. We do this so we don't hold I_SYNC against an inode for
  645. * enormous amounts of time, which would block a userspace task which has
  646. * been forced to throttle against that inode. Also, the code reevaluates
  647. * the dirty each time it has written this many pages.
  648. */
  649. #define MAX_WRITEBACK_PAGES 1024
  650. static inline bool over_bground_thresh(void)
  651. {
  652. unsigned long background_thresh, dirty_thresh;
  653. get_dirty_limits(&background_thresh, &dirty_thresh, NULL, NULL);
  654. return (global_page_state(NR_FILE_DIRTY) +
  655. global_page_state(NR_UNSTABLE_NFS) >= background_thresh);
  656. }
  657. /*
  658. * Explicit flushing or periodic writeback of "old" data.
  659. *
  660. * Define "old": the first time one of an inode's pages is dirtied, we mark the
  661. * dirtying-time in the inode's address_space. So this periodic writeback code
  662. * just walks the superblock inode list, writing back any inodes which are
  663. * older than a specific point in time.
  664. *
  665. * Try to run once per dirty_writeback_interval. But if a writeback event
  666. * takes longer than a dirty_writeback_interval interval, then leave a
  667. * one-second gap.
  668. *
  669. * older_than_this takes precedence over nr_to_write. So we'll only write back
  670. * all dirty pages if they are all attached to "old" mappings.
  671. */
  672. static long wb_writeback(struct bdi_writeback *wb,
  673. struct wb_writeback_args *args)
  674. {
  675. struct writeback_control wbc = {
  676. .bdi = wb->bdi,
  677. .sb = args->sb,
  678. .sync_mode = args->sync_mode,
  679. .older_than_this = NULL,
  680. .for_kupdate = args->for_kupdate,
  681. .for_background = args->for_background,
  682. .range_cyclic = args->range_cyclic,
  683. };
  684. unsigned long oldest_jif;
  685. long wrote = 0;
  686. struct inode *inode;
  687. if (wbc.for_kupdate) {
  688. wbc.older_than_this = &oldest_jif;
  689. oldest_jif = jiffies -
  690. msecs_to_jiffies(dirty_expire_interval * 10);
  691. }
  692. if (!wbc.range_cyclic) {
  693. wbc.range_start = 0;
  694. wbc.range_end = LLONG_MAX;
  695. }
  696. for (;;) {
  697. /*
  698. * Stop writeback when nr_pages has been consumed
  699. */
  700. if (args->nr_pages <= 0)
  701. break;
  702. /*
  703. * For background writeout, stop when we are below the
  704. * background dirty threshold
  705. */
  706. if (args->for_background && !over_bground_thresh())
  707. break;
  708. wbc.more_io = 0;
  709. wbc.nr_to_write = MAX_WRITEBACK_PAGES;
  710. wbc.pages_skipped = 0;
  711. writeback_inodes_wb(wb, &wbc);
  712. args->nr_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write;
  713. wrote += MAX_WRITEBACK_PAGES - wbc.nr_to_write;
  714. /*
  715. * If we consumed everything, see if we have more
  716. */
  717. if (wbc.nr_to_write <= 0)
  718. continue;
  719. /*
  720. * Didn't write everything and we don't have more IO, bail
  721. */
  722. if (!wbc.more_io)
  723. break;
  724. /*
  725. * Did we write something? Try for more
  726. */
  727. if (wbc.nr_to_write < MAX_WRITEBACK_PAGES)
  728. continue;
  729. /*
  730. * Nothing written. Wait for some inode to
  731. * become available for writeback. Otherwise
  732. * we'll just busyloop.
  733. */
  734. spin_lock(&inode_lock);
  735. if (!list_empty(&wb->b_more_io)) {
  736. inode = list_entry(wb->b_more_io.prev,
  737. struct inode, i_list);
  738. inode_wait_for_writeback(inode);
  739. }
  740. spin_unlock(&inode_lock);
  741. }
  742. return wrote;
  743. }
  744. /*
  745. * Return the next bdi_work struct that hasn't been processed by this
  746. * wb thread yet. ->seen is initially set for each thread that exists
  747. * for this device, when a thread first notices a piece of work it
  748. * clears its bit. Depending on writeback type, the thread will notify
  749. * completion on either receiving the work (WB_SYNC_NONE) or after
  750. * it is done (WB_SYNC_ALL).
  751. */
  752. static struct bdi_work *get_next_work_item(struct backing_dev_info *bdi,
  753. struct bdi_writeback *wb)
  754. {
  755. struct bdi_work *work, *ret = NULL;
  756. rcu_read_lock();
  757. list_for_each_entry_rcu(work, &bdi->work_list, list) {
  758. if (!test_bit(wb->nr, &work->seen))
  759. continue;
  760. clear_bit(wb->nr, &work->seen);
  761. ret = work;
  762. break;
  763. }
  764. rcu_read_unlock();
  765. return ret;
  766. }
  767. static long wb_check_old_data_flush(struct bdi_writeback *wb)
  768. {
  769. unsigned long expired;
  770. long nr_pages;
  771. /*
  772. * When set to zero, disable periodic writeback
  773. */
  774. if (!dirty_writeback_interval)
  775. return 0;
  776. expired = wb->last_old_flush +
  777. msecs_to_jiffies(dirty_writeback_interval * 10);
  778. if (time_before(jiffies, expired))
  779. return 0;
  780. wb->last_old_flush = jiffies;
  781. nr_pages = global_page_state(NR_FILE_DIRTY) +
  782. global_page_state(NR_UNSTABLE_NFS) +
  783. (inodes_stat.nr_inodes - inodes_stat.nr_unused);
  784. if (nr_pages) {
  785. struct wb_writeback_args args = {
  786. .nr_pages = nr_pages,
  787. .sync_mode = WB_SYNC_NONE,
  788. .for_kupdate = 1,
  789. .range_cyclic = 1,
  790. };
  791. return wb_writeback(wb, &args);
  792. }
  793. return 0;
  794. }
  795. /*
  796. * Retrieve work items and do the writeback they describe
  797. */
  798. long wb_do_writeback(struct bdi_writeback *wb, int force_wait)
  799. {
  800. struct backing_dev_info *bdi = wb->bdi;
  801. struct bdi_work *work;
  802. long wrote = 0;
  803. while ((work = get_next_work_item(bdi, wb)) != NULL) {
  804. struct wb_writeback_args args = work->args;
  805. /*
  806. * Override sync mode, in case we must wait for completion
  807. */
  808. if (force_wait)
  809. work->args.sync_mode = args.sync_mode = WB_SYNC_ALL;
  810. /*
  811. * If this isn't a data integrity operation, just notify
  812. * that we have seen this work and we are now starting it.
  813. */
  814. if (args.sync_mode == WB_SYNC_NONE)
  815. wb_clear_pending(wb, work);
  816. wrote += wb_writeback(wb, &args);
  817. /*
  818. * This is a data integrity writeback, so only do the
  819. * notification when we have completed the work.
  820. */
  821. if (args.sync_mode == WB_SYNC_ALL)
  822. wb_clear_pending(wb, work);
  823. }
  824. /*
  825. * Check for periodic writeback, kupdated() style
  826. */
  827. wrote += wb_check_old_data_flush(wb);
  828. return wrote;
  829. }
  830. /*
  831. * Handle writeback of dirty data for the device backed by this bdi. Also
  832. * wakes up periodically and does kupdated style flushing.
  833. */
  834. int bdi_writeback_task(struct bdi_writeback *wb)
  835. {
  836. unsigned long last_active = jiffies;
  837. unsigned long wait_jiffies = -1UL;
  838. long pages_written;
  839. while (!kthread_should_stop()) {
  840. pages_written = wb_do_writeback(wb, 0);
  841. if (pages_written)
  842. last_active = jiffies;
  843. else if (wait_jiffies != -1UL) {
  844. unsigned long max_idle;
  845. /*
  846. * Longest period of inactivity that we tolerate. If we
  847. * see dirty data again later, the task will get
  848. * recreated automatically.
  849. */
  850. max_idle = max(5UL * 60 * HZ, wait_jiffies);
  851. if (time_after(jiffies, max_idle + last_active))
  852. break;
  853. }
  854. if (dirty_writeback_interval) {
  855. wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10);
  856. schedule_timeout_interruptible(wait_jiffies);
  857. } else {
  858. set_current_state(TASK_INTERRUPTIBLE);
  859. if (list_empty_careful(&wb->bdi->work_list) &&
  860. !kthread_should_stop())
  861. schedule();
  862. __set_current_state(TASK_RUNNING);
  863. }
  864. try_to_freeze();
  865. }
  866. return 0;
  867. }
  868. /*
  869. * Schedule writeback for all backing devices. This does WB_SYNC_NONE
  870. * writeback, for integrity writeback see bdi_sync_writeback().
  871. */
  872. static void bdi_writeback_all(struct super_block *sb, long nr_pages)
  873. {
  874. struct wb_writeback_args args = {
  875. .sb = sb,
  876. .nr_pages = nr_pages,
  877. .sync_mode = WB_SYNC_NONE,
  878. };
  879. struct backing_dev_info *bdi;
  880. rcu_read_lock();
  881. list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) {
  882. if (!bdi_has_dirty_io(bdi))
  883. continue;
  884. bdi_alloc_queue_work(bdi, &args);
  885. }
  886. rcu_read_unlock();
  887. }
  888. /*
  889. * Start writeback of `nr_pages' pages. If `nr_pages' is zero, write back
  890. * the whole world.
  891. */
  892. void wakeup_flusher_threads(long nr_pages)
  893. {
  894. if (nr_pages == 0)
  895. nr_pages = global_page_state(NR_FILE_DIRTY) +
  896. global_page_state(NR_UNSTABLE_NFS);
  897. bdi_writeback_all(NULL, nr_pages);
  898. }
  899. static noinline void block_dump___mark_inode_dirty(struct inode *inode)
  900. {
  901. if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev")) {
  902. struct dentry *dentry;
  903. const char *name = "?";
  904. dentry = d_find_alias(inode);
  905. if (dentry) {
  906. spin_lock(&dentry->d_lock);
  907. name = (const char *) dentry->d_name.name;
  908. }
  909. printk(KERN_DEBUG
  910. "%s(%d): dirtied inode %lu (%s) on %s\n",
  911. current->comm, task_pid_nr(current), inode->i_ino,
  912. name, inode->i_sb->s_id);
  913. if (dentry) {
  914. spin_unlock(&dentry->d_lock);
  915. dput(dentry);
  916. }
  917. }
  918. }
  919. /**
  920. * __mark_inode_dirty - internal function
  921. * @inode: inode to mark
  922. * @flags: what kind of dirty (i.e. I_DIRTY_SYNC)
  923. * Mark an inode as dirty. Callers should use mark_inode_dirty or
  924. * mark_inode_dirty_sync.
  925. *
  926. * Put the inode on the super block's dirty list.
  927. *
  928. * CAREFUL! We mark it dirty unconditionally, but move it onto the
  929. * dirty list only if it is hashed or if it refers to a blockdev.
  930. * If it was not hashed, it will never be added to the dirty list
  931. * even if it is later hashed, as it will have been marked dirty already.
  932. *
  933. * In short, make sure you hash any inodes _before_ you start marking
  934. * them dirty.
  935. *
  936. * This function *must* be atomic for the I_DIRTY_PAGES case -
  937. * set_page_dirty() is called under spinlock in several places.
  938. *
  939. * Note that for blockdevs, inode->dirtied_when represents the dirtying time of
  940. * the block-special inode (/dev/hda1) itself. And the ->dirtied_when field of
  941. * the kernel-internal blockdev inode represents the dirtying time of the
  942. * blockdev's pages. This is why for I_DIRTY_PAGES we always use
  943. * page->mapping->host, so the page-dirtying time is recorded in the internal
  944. * blockdev inode.
  945. */
  946. void __mark_inode_dirty(struct inode *inode, int flags)
  947. {
  948. struct super_block *sb = inode->i_sb;
  949. /*
  950. * Don't do this for I_DIRTY_PAGES - that doesn't actually
  951. * dirty the inode itself
  952. */
  953. if (flags & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) {
  954. if (sb->s_op->dirty_inode)
  955. sb->s_op->dirty_inode(inode);
  956. }
  957. /*
  958. * make sure that changes are seen by all cpus before we test i_state
  959. * -- mikulas
  960. */
  961. smp_mb();
  962. /* avoid the locking if we can */
  963. if ((inode->i_state & flags) == flags)
  964. return;
  965. if (unlikely(block_dump))
  966. block_dump___mark_inode_dirty(inode);
  967. spin_lock(&inode_lock);
  968. if ((inode->i_state & flags) != flags) {
  969. const int was_dirty = inode->i_state & I_DIRTY;
  970. inode->i_state |= flags;
  971. /*
  972. * If the inode is being synced, just update its dirty state.
  973. * The unlocker will place the inode on the appropriate
  974. * superblock list, based upon its state.
  975. */
  976. if (inode->i_state & I_SYNC)
  977. goto out;
  978. /*
  979. * Only add valid (hashed) inodes to the superblock's
  980. * dirty list. Add blockdev inodes as well.
  981. */
  982. if (!S_ISBLK(inode->i_mode)) {
  983. if (hlist_unhashed(&inode->i_hash))
  984. goto out;
  985. }
  986. if (inode->i_state & (I_FREEING|I_CLEAR))
  987. goto out;
  988. /*
  989. * If the inode was already on b_dirty/b_io/b_more_io, don't
  990. * reposition it (that would break b_dirty time-ordering).
  991. */
  992. if (!was_dirty) {
  993. struct bdi_writeback *wb = &inode_to_bdi(inode)->wb;
  994. struct backing_dev_info *bdi = wb->bdi;
  995. if (bdi_cap_writeback_dirty(bdi) &&
  996. !test_bit(BDI_registered, &bdi->state)) {
  997. WARN_ON(1);
  998. printk(KERN_ERR "bdi-%s not registered\n",
  999. bdi->name);
  1000. }
  1001. inode->dirtied_when = jiffies;
  1002. list_move(&inode->i_list, &wb->b_dirty);
  1003. }
  1004. }
  1005. out:
  1006. spin_unlock(&inode_lock);
  1007. }
  1008. EXPORT_SYMBOL(__mark_inode_dirty);
  1009. /*
  1010. * Write out a superblock's list of dirty inodes. A wait will be performed
  1011. * upon no inodes, all inodes or the final one, depending upon sync_mode.
  1012. *
  1013. * If older_than_this is non-NULL, then only write out inodes which
  1014. * had their first dirtying at a time earlier than *older_than_this.
  1015. *
  1016. * If `bdi' is non-zero then we're being asked to writeback a specific queue.
  1017. * This function assumes that the blockdev superblock's inodes are backed by
  1018. * a variety of queues, so all inodes are searched. For other superblocks,
  1019. * assume that all inodes are backed by the same queue.
  1020. *
  1021. * The inodes to be written are parked on bdi->b_io. They are moved back onto
  1022. * bdi->b_dirty as they are selected for writing. This way, none can be missed
  1023. * on the writer throttling path, and we get decent balancing between many
  1024. * throttled threads: we don't want them all piling up on inode_sync_wait.
  1025. */
  1026. static void wait_sb_inodes(struct super_block *sb)
  1027. {
  1028. struct inode *inode, *old_inode = NULL;
  1029. /*
  1030. * We need to be protected against the filesystem going from
  1031. * r/o to r/w or vice versa.
  1032. */
  1033. WARN_ON(!rwsem_is_locked(&sb->s_umount));
  1034. spin_lock(&inode_lock);
  1035. /*
  1036. * Data integrity sync. Must wait for all pages under writeback,
  1037. * because there may have been pages dirtied before our sync
  1038. * call, but which had writeout started before we write it out.
  1039. * In which case, the inode may not be on the dirty list, but
  1040. * we still have to wait for that writeout.
  1041. */
  1042. list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
  1043. struct address_space *mapping;
  1044. if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE|I_NEW))
  1045. continue;
  1046. mapping = inode->i_mapping;
  1047. if (mapping->nrpages == 0)
  1048. continue;
  1049. __iget(inode);
  1050. spin_unlock(&inode_lock);
  1051. /*
  1052. * We hold a reference to 'inode' so it couldn't have
  1053. * been removed from s_inodes list while we dropped the
  1054. * inode_lock. We cannot iput the inode now as we can
  1055. * be holding the last reference and we cannot iput it
  1056. * under inode_lock. So we keep the reference and iput
  1057. * it later.
  1058. */
  1059. iput(old_inode);
  1060. old_inode = inode;
  1061. filemap_fdatawait(mapping);
  1062. cond_resched();
  1063. spin_lock(&inode_lock);
  1064. }
  1065. spin_unlock(&inode_lock);
  1066. iput(old_inode);
  1067. }
  1068. /**
  1069. * writeback_inodes_sb - writeback dirty inodes from given super_block
  1070. * @sb: the superblock
  1071. *
  1072. * Start writeback on some inodes on this super_block. No guarantees are made
  1073. * on how many (if any) will be written, and this function does not wait
  1074. * for IO completion of submitted IO. The number of pages submitted is
  1075. * returned.
  1076. */
  1077. void writeback_inodes_sb(struct super_block *sb)
  1078. {
  1079. unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY);
  1080. unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS);
  1081. long nr_to_write;
  1082. nr_to_write = nr_dirty + nr_unstable +
  1083. (inodes_stat.nr_inodes - inodes_stat.nr_unused);
  1084. bdi_start_writeback(sb->s_bdi, sb, nr_to_write);
  1085. }
  1086. EXPORT_SYMBOL(writeback_inodes_sb);
  1087. /**
  1088. * writeback_inodes_sb_if_idle - start writeback if none underway
  1089. * @sb: the superblock
  1090. *
  1091. * Invoke writeback_inodes_sb if no writeback is currently underway.
  1092. * Returns 1 if writeback was started, 0 if not.
  1093. */
  1094. int writeback_inodes_sb_if_idle(struct super_block *sb)
  1095. {
  1096. if (!writeback_in_progress(sb->s_bdi)) {
  1097. writeback_inodes_sb(sb);
  1098. return 1;
  1099. } else
  1100. return 0;
  1101. }
  1102. EXPORT_SYMBOL(writeback_inodes_sb_if_idle);
  1103. /**
  1104. * sync_inodes_sb - sync sb inode pages
  1105. * @sb: the superblock
  1106. *
  1107. * This function writes and waits on any dirty inode belonging to this
  1108. * super_block. The number of pages synced is returned.
  1109. */
  1110. void sync_inodes_sb(struct super_block *sb)
  1111. {
  1112. bdi_sync_writeback(sb->s_bdi, sb);
  1113. wait_sb_inodes(sb);
  1114. }
  1115. EXPORT_SYMBOL(sync_inodes_sb);
  1116. /**
  1117. * write_inode_now - write an inode to disk
  1118. * @inode: inode to write to disk
  1119. * @sync: whether the write should be synchronous or not
  1120. *
  1121. * This function commits an inode to disk immediately if it is dirty. This is
  1122. * primarily needed by knfsd.
  1123. *
  1124. * The caller must either have a ref on the inode or must have set I_WILL_FREE.
  1125. */
  1126. int write_inode_now(struct inode *inode, int sync)
  1127. {
  1128. int ret;
  1129. struct writeback_control wbc = {
  1130. .nr_to_write = LONG_MAX,
  1131. .sync_mode = sync ? WB_SYNC_ALL : WB_SYNC_NONE,
  1132. .range_start = 0,
  1133. .range_end = LLONG_MAX,
  1134. };
  1135. if (!mapping_cap_writeback_dirty(inode->i_mapping))
  1136. wbc.nr_to_write = 0;
  1137. might_sleep();
  1138. spin_lock(&inode_lock);
  1139. ret = writeback_single_inode(inode, &wbc);
  1140. spin_unlock(&inode_lock);
  1141. if (sync)
  1142. inode_sync_wait(inode);
  1143. return ret;
  1144. }
  1145. EXPORT_SYMBOL(write_inode_now);
  1146. /**
  1147. * sync_inode - write an inode and its pages to disk.
  1148. * @inode: the inode to sync
  1149. * @wbc: controls the writeback mode
  1150. *
  1151. * sync_inode() will write an inode and its pages to disk. It will also
  1152. * correctly update the inode on its superblock's dirty inode lists and will
  1153. * update inode->i_state.
  1154. *
  1155. * The caller must have a ref on the inode.
  1156. */
  1157. int sync_inode(struct inode *inode, struct writeback_control *wbc)
  1158. {
  1159. int ret;
  1160. spin_lock(&inode_lock);
  1161. ret = writeback_single_inode(inode, wbc);
  1162. spin_unlock(&inode_lock);
  1163. return ret;
  1164. }
  1165. EXPORT_SYMBOL(sync_inode);