Skip to content
Snippets Groups Projects
Select Git revision
  • 5a3f23d515a2ebf0c750db80579ca57b28cbce6d
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

ordered-data.c

Blame
    • Chris Mason's avatar
      5a3f23d5
      Btrfs: add extra flushing for renames and truncates · 5a3f23d5
      Chris Mason authored
      
      Renames and truncates are both common ways to replace old data with new
      data.  The filesystem can make an effort to make sure the new data is
      on disk before actually replacing the old data.
      
      This is especially important for rename, which many application use as
      though it were atomic for both the data and the metadata involved.  The
      current btrfs code will happily replace a file that is fully on disk
      with one that was just created and still has pending IO.
      
      If we crash after transaction commit but before the IO is done, we'll end
      up replacing a good file with a zero length file.  The solution used
      here is to create a list of inodes that need special ordering and force
      them to disk before the commit is done.  This is similar to the
      ext3 style data=ordering, except it is only done on selected files.
      
      Btrfs is able to get away with this because it does not wait on commits
      very often, even for fsync (which use a sub-commit).
      
      For renames, we order the file when it wasn't already
      on disk and when it is replacing an existing file.  Larger files
      are sent to filemap_flush right away (before the transaction handle is
      opened).
      
      For truncates, we order if the file goes from non-zero size down to
      zero size.  This is a little different, because at the time of the
      truncate the file has no dirty bytes to order.  But, we flag the inode
      so that it is added to the ordered list on close (via release method).  We
      also immediately add it to the ordered list of the current transaction
      so that we can try to flush down any writes the application sneaks in
      before commit.
      
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      5a3f23d5
      History
      Btrfs: add extra flushing for renames and truncates
      Chris Mason authored
      
      Renames and truncates are both common ways to replace old data with new
      data.  The filesystem can make an effort to make sure the new data is
      on disk before actually replacing the old data.
      
      This is especially important for rename, which many application use as
      though it were atomic for both the data and the metadata involved.  The
      current btrfs code will happily replace a file that is fully on disk
      with one that was just created and still has pending IO.
      
      If we crash after transaction commit but before the IO is done, we'll end
      up replacing a good file with a zero length file.  The solution used
      here is to create a list of inodes that need special ordering and force
      them to disk before the commit is done.  This is similar to the
      ext3 style data=ordering, except it is only done on selected files.
      
      Btrfs is able to get away with this because it does not wait on commits
      very often, even for fsync (which use a sub-commit).
      
      For renames, we order the file when it wasn't already
      on disk and when it is replacing an existing file.  Larger files
      are sent to filemap_flush right away (before the transaction handle is
      opened).
      
      For truncates, we order if the file goes from non-zero size down to
      zero size.  This is a little different, because at the time of the
      truncate the file has no dirty bytes to order.  But, we flag the inode
      so that it is added to the ordered list on close (via release method).  We
      also immediately add it to the ordered list of the current transaction
      so that we can try to flush down any writes the application sneaks in
      before commit.
      
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
    backoff.h 514 B
    #ifndef _SPARC64_BACKOFF_H
    #define _SPARC64_BACKOFF_H
    
    #define BACKOFF_LIMIT	(4 * 1024)
    
    #ifdef CONFIG_SMP
    
    #define BACKOFF_SETUP(reg)	\
    	mov	1, reg
    
    #define BACKOFF_SPIN(reg, tmp, label)	\
    	mov	reg, tmp; \
    88:	brnz,pt	tmp, 88b; \
    	 sub	tmp, 1, tmp; \
    	set	BACKOFF_LIMIT, tmp; \
    	cmp	reg, tmp; \
    	bg,pn	%xcc, label; \
    	 nop; \
    	ba,pt	%xcc, label; \
    	 sllx	reg, 1, reg;
    
    #else
    
    #define BACKOFF_SETUP(reg)
    #define BACKOFF_SPIN(reg, tmp, label) \
    	ba,pt	%xcc, label; \
    	 nop;
    
    #endif
    
    #endif /* _SPARC64_BACKOFF_H */