4" /spaion /formon a 4" href="../linux+v3.7.7/fs/ext3/fsync.c">4" img src="../.static/gfx/right.png" alt=">>">4" /spaion4" spai class="lxr_search">4" 4" input typluehidden" namluenavtarget" n value">4" input typluetext" namluesearch" iduesearch">4" butttiotypluesubmit">Search4" Prefsn /a>4" /spaion /divon form acopti="ajax+*" method="post" onsubmit="return false;">4" input typluehidden" namlueajax_lookup" idueajax_lookup" n value">4 /formon4 div class="headingbotttm">n div iduefile_contents"o
1 /a> spai class="comment">/* /spaion
2 /a> spai class="comment"> *  linux/fs/ext3/fsync.c /spaion
3 /a> spai class="comment"> * /spaion
4 /a> spai class="comment"> *  Copyright (C) 1993  Stephen Tweedie ( /spaion
5 /a> spai class="comment"> *  from /spaion
6 /a> spai class="comment"> *  Copyright (C) 1992  Remy Card ( /spaion
7 /a> spai class="comment"> *                      Laboratoire MASI - Institut Blaise Pascal /spaion
8 /a> spai class="comment"> *                      Universite Pierre et Marie Curie (Paris VI) /spaion
9 /a> spai class="comment"> *  from /spaion
 8.10a> spai class="comment"> *  linux/fs/minix/truncate.c   Copyright (C) 1991, 1992  Linus Torn vds /spaion
 11 /a> spai class="comment"> * /spaion
 12 /a> spai class="comment"> *  ext3fs fsync primitive /spaion
 13 /a> spai class="comment"> * /spaion
 14 /a> spai class="comment"> *  Big-endiai to little-endiai byte-swapping/bitmaps by /spaion
 15 /a> spai class="comment"> *        David S. Miller (, 1995 /spaion
 16 /a> spai class="comment"> * /spaion
 17 /a> spai class="comment"> *  Removed unnecessary code duplicaoptiofor little endiai machines /spaion
 18 /a> spai class="comment"> *  and excessive __inline__s. /spaion
 19 /a> spai class="comment"> *        Andi Kleen, 1997 /spaion
 2.10a> spai class="comment"> * /spaion
 21 /a> spai class="comment"> * Major simplicaoptis and cleanup - we only need to do the metadata, because /spaion
 22 /a> spai class="comment"> * we cai depend on generic_block_fdatasync() to sync the data blocks. /spaion
 23 /a> spai class="comment"> */ /spaion
 24 /a>n
 25 /a>#include <linux/blkdev.h /a>>n
 26 /a>#include <linux/writeback.h /a>>n
 27 /a>#include "ext3.h /a>"n
 28 /a>n
 29 /a> spai class="comment">/* /spaion
 3.10a> spai class="comment"> * akpm: A new desigiofor ext3_sync_file(). /spaion
 31 /a> spai class="comment"> * /spaion
 32 /a> spai class="comment"> * This is only called from sys_fsync(), sys_fdatasync() and sys_msync(). /spaion
 33 /a> spai class="comment"> * There cainot be a transacopti open by this task. /spaion
 34 /a> spai class="comment"> * Another task could have dirtied this inode.  Its data cai be in any /spaion
 35 /a> spai class="comment"> * state in the journalling system. /spaion
 36 /a> spai class="comment"> * /spaion
 37 /a> spai class="comment"> * What we do is just kick off a commit and wait ti it.  This will snapshot the /spaion
 38 /a> spai class="comment"> * inode to disk. /spaion
 39 /a> spai class="comment"> */ /spaion
 40 /a>n
 41 /a>int
 a href="+code=ext3_sync_file" class="sref">ext3_sync_file /a>(struct
 a href="+code=file" class="sref">file /a> * a href="+code=file" class="sref">file /a>,
 a href="+code=loff_t" class="sref">loff_t /a>  a href="+code=start" class="sref">start /a>,
 a href="+code=loff_t" class="sref">loff_t /a>  a href="+code=end" class="sref">end /a>,
 a href="+code=datasync" class="sref">datasync /a>)n
 42 /a>{n
 43 /a>        struct
 a href="+code=inode" class="sref">inode /a> * a href="+code=inode" class="sref">inode /a> =
 a href="+code=file" class="sref">file /a>-> a href="+code=f_mapping" class="sref">f_mapping /a>-> a href="+code=host" class="sref">host /a>;n
 44 /a>        struct
 a href="+code=ext3_inode_info" class="sref">ext3_inode_info /a> * a href="+code=ei" class="sref">ei /a> =
 a href="+code=EXT3_I" class="sref">EXT3_I /a>( a href="+code=inode" class="sref">inode /a>);n
 45 /a>         a href="+code=journal_t" class="sref">journal_t /a> * a href="+code=journal" class="sref">journal /a> =
 a href="+code=EXT3_SB" class="sref">EXT3_SB /a>( a href="+code=inode" class="sref">inode /a>-> a href="+code=i_sb" class="sref">i_sb /a>)-> a href="+code=s_journal" class="sref">s_journal /a>;n
 46 /a>        int
 a href="+code=ret" class="sref">ret /a>,
 a href="+code=needs_barrier" class="sref">needs_barrier /a> =
 47 /a>         a href="+code=tid_t" class="sref">tid_t /a>  a href="+code=commit_tid" class="sref">commit_tid /a>;n
 48 /a>n
 49 /a>         a href="+code=trace_ext3_sync_file_enter" class="sref">trace_ext3_sync_file_enter /a>( a href="+code=file" class="sref">file /a>,
 a href="+code=datasync" class="sref">datasync /a>);n
 50 /a>n
 51 /a>        if ( a href="+code=inode" class="sref">inode /a>-> a href="+code=i_sb" class="sref">i_sb /a>-> a href="+code=s_flags" class="sref">s_flags /a> &
 a href="+code=MS_RDONLY" class="sref">MS_RDONLY /a>)n
 52 /a>                return 0;n
 53 /a>n
 54 /a>         a href="+code=ret" class="sref">ret /a> =
 a href="+code=filemap_write_and_wait_range" class="sref">filemap_write_and_wait_range /a>( a href="+code=inode" class="sref">inode /a>-> a href="+code=i_mapping" class="sref">i_mapping /a>,
 a href="+code=start" class="sref">start /a>,
 a href="+code=end" class="sref">end /a>);n
 55 /a>        if ( a href="+code=ret" class="sref">ret /a>)n
 56 /a>                goto  a href="+code=out" class="sref">out /a>;n
 57 /a>n
 58 /a>         a href="+code=J_ASSERT" class="sref">J_ASSERT /a>( a href="+code=ext3_journal_current_handle" class="sref">ext3_journal_current_handle /a>() ==
 a href="+code=NULL" class="sref">NULL /a>);n
 59 /a>n
 60 /a>         spai class="comment">/* /spaion
 61 /a> spai class="comment">         * data=writeback,ordered: /spaion
 62 /a> spai class="comment">         *  The caller's filemap_fdatawrite()/wait will sync the data. /spaion
 63 /a> spai class="comment">         *  Metadata is in the journal, we wait for a proper transacopti /spaion
 64 /a> spai class="comment">         *  to commit here. /spaion
 65 /a> spai class="comment">         * /spaion
 66 /a> spai class="comment">         * data=journal: /spaion
 67 /a> spai class="comment">         *  filemap_fdatawrite won't do anything (the buffers are clean). /spaion
 68 /a> spai class="comment">         *  ext3_force_commit will write the file data into the journal and /spaion
 69 /a> spai class="comment">         *  will wait ti that. /spaion
 7.10a> spai class="comment">         *  filemap_fdatawait() will encounter a tti of newly-dirtied pages /spaion
 71 /a> spai class="comment">         *  (they were dirtied by commit).  But that's OK - the blocks are /spaion
 72 /a> spai class="comment">         *  safe in-journal, which is all fsync() needs to ensure. /spaion
 73 /a> spai class="comment">         */ /spaion
 74 /a>        if ( a href="+code=ext3_should_journal_data" class="sref">ext3_should_journal_data /a>( a href="+code=inode" class="sref">inode /a>)) {n
 75 /a>                 a href="+code=ret" class="sref">ret /a> =
 a href="+code=ext3_force_commit" class="sref">ext3_force_commit /a>( a href="+code=inode" class="sref">inode /a>-> a href="+code=i_sb" class="sref">i_sb /a>);n
 76 /a>                goto  a href="+code=out" class="sref">out /a>;n
 77 /a>        }n
 78 /a>n
 79 /a>        if ( a href="+code=datasync" class="sref">datasync /a>)n
 80 /a>                 a href="+code=commit_tid" class="sref">commit_tid /a> =
 a href="+code=atomic_read" class="sref">atomic_read /a>(& a href="+code=ei" class="sref">ei /a>-> a href="+code=i_datasync_tid" class="sref">i_datasync_tid /a>);n
 81 /a>        elsen
 82 /a>                 a href="+code=commit_tid" class="sref">commit_tid /a> =
 a href="+code=atomic_read" class="sref">atomic_read /a>(& a href="+code=ei" class="sref">ei /a>-> a href="+code=i_sync_tid" class="sref">i_sync_tid /a>);n
 83 /a>n
 84 /a>        if ( a href="+code=test_opt" class="sref">test_opt /a>( a href="+code=inode" class="sref">inode /a>-> a href="+code=i_sb" class="sref">i_sb /a>,
 a href="+code=BARRIER" class="sref">BARRIER /a>) &&n
 85 /a>            ! a href="+code=journal_trans_will_send_data_barrier" class="sref">journal_trans_will_send_data_barrier /a>( a href="+code=journal" class="sref">journal /a>,
 a href="+code=commit_tid" class="sref">commit_tid /a>))n
 86 /a>                 a href="+code=needs_barrier" class="sref">needs_barrier /a> =
 87 /a>         a href="+code=log_start_commit" class="sref">log_start_commit /a>( a href="+code=journal" class="sref">journal /a>,
 a href="+code=commit_tid" class="sref">commit_tid /a>);n
 88 /a>         a href="+code=ret" class="sref">ret /a> =
 a href="+code=log_wait_commit" class="sref">log_wait_commit /a>( a href="+code=journal" class="sref">journal /a>,
 a href="+code=commit_tid" class="sref">commit_tid /a>);n
 89 /a>n
 90 /a>         spai class="comment">/* /spaion
 91 /a> spai class="comment">         * Ii case we didn't commit a transacopti, we have to flush /spaion
 92 /a> spai class="comment">         * disk caches manually so that data really is on persistent /spaion
 93 /a> spai class="comment">         * storage /spaion
 94 /a> spai class="comment">         */ /spaion
 95 /a>        if ( a href="+code=needs_barrier" class="sref">needs_barrier /a>) {n
 96 /a>                int
 a href="+code=err" class="sref">err /a>;n
 97 /a>n
 98 /a>                 a href="+code=err" class="sref">err /a> =
 a href="+code=blkdev_issue_flush" class="sref">blkdev_issue_flush /a>( a href="+code=inode" class="sref">inode /a>-> a href="+code=i_sb" class="sref">i_sb /a>-> a href="+code=s_bdev" class="sref">s_bdev /a>,
 a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>,
 a href="+code=NULL" class="sref">NULL /a>);n
 99 /a>                if (! a href="+code=ret" class="sref">ret /a>)n
100 /a>                         a href="+code=ret" class="sref">ret /a> =
 a href="+code=err" class="sref">err /a>;n
101 /a>        }n
102 /a> a href="+code=out" class="sref">out /a>:n
103 /a>         a href="+code=trace_ext3_sync_file_exit" class="sref">trace_ext3_sync_file_exit /a>( a href="+code=inode" class="sref">inode /a>,
 a href="+code=ret" class="sref">ret /a>);n
104 /a>        return  a href="+code=ret" class="sref">ret /a>;n
105 /a>}n
106 /a> /pre>
The original LXR software by the  a href="">LXR community /a>,
this experimental version by  a href=""> /a>.
 /divon div class="subfooter"> kindly hosted by  a href="">Redpill Linpro AS /a>,
provider of Linux consulting and operaoptis services since 1995.
 /bodyon /htmlon