The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/ext3/fsync.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  *  linux/fs/ext3/fsync.c
    3  *
    4  *  Copyright (C) 1993  Stephen Tweedie (sct@redhat.com)
    5  *  from
    6  *  Copyright (C) 1992  Remy Card (card@masi.ibp.fr)
    7  *                      Laboratoire MASI - Institut Blaise Pascal
    8  *                      Universite Pierre et Marie Curie (Paris VI)
    9  *  from
   10  *  linux/fs/minix/truncate.c   Copyright (C) 1991, 1992  Linus Torvalds
   11  * 
   12  *  ext3fs fsync primitive
   13  *
   14  *  Big-endian to little-endian byte-swapping/bitmaps by
   15  *        David S. Miller (davem@caip.rutgers.edu), 1995
   16  * 
   17  *  Removed unnecessary code duplication for little endian machines
   18  *  and excessive __inline__s. 
   19  *        Andi Kleen, 1997
   20  *
   21  * Major simplications and cleanup - we only need to do the metadata, because
   22  * we can depend on generic_block_fdatasync() to sync the data blocks.
   23  */
   24 
   25 #include <linux/sched.h>
   26 #include <linux/fs.h>
   27 #include <linux/jbd.h>
   28 #include <linux/ext3_fs.h>
   29 #include <linux/ext3_jbd.h>
   30 #include <linux/jbd.h>
   31 #include <linux/smp_lock.h>
   32 
   33 /*
   34  * akpm: A new design for ext3_sync_file().
   35  *
   36  * This is only called from sys_fsync(), sys_fdatasync() and sys_msync().
   37  * There cannot be a transaction open by this task. (AKPM: quotas?)
   38  * Another task could have dirtied this inode.  Its data can be in any
   39  * state in the journalling system.
   40  *
   41  * What we do is just kick off a commit and wait on it.  This will snapshot the
   42  * inode to disk.
   43  *
   44  * Note that there is a serious optimisation we can make here: if the current
   45  * inode is not part of j_running_transaction or j_committing_transaction
   46  * then we have nothing to do.  That would require implementation of t_ilist,
   47  * which isn't too hard.
   48  */
   49 
   50 int ext3_sync_file(struct file * file, struct dentry *dentry, int datasync)
   51 {
   52         struct inode *inode = dentry->d_inode;
   53         int ret;
   54 
   55         J_ASSERT(ext3_journal_current_handle() == 0);
   56 
   57         /*
   58          * fsync_inode_buffers() just walks i_dirty_buffers and waits
   59          * on them.  It's a no-op for full data journalling because
   60          * i_dirty_buffers will be ampty.
   61          * Really, we only need to start I/O on the dirty buffers -
   62          * we'll end up waiting on them in commit.
   63          */
   64         ret = fsync_inode_buffers(inode);
   65 
   66         /* In writeback mode, we need to force out data buffers too.  In
   67          * the other modes, ext3_force_commit takes care of forcing out
   68          * just the right data blocks. */
   69         if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
   70                 ret |= fsync_inode_data_buffers(inode);
   71 
   72         ext3_force_commit(inode->i_sb);
   73 
   74         return ret;
   75 }

Cache object: 0dc23f3d8dfa68693e6acdc8b9ce6b05


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.