]> Pileus Git - ~andy/linux/blobdiff - fs/xfs/xfs_iomap.c
Merge tag 'for-linus-v3.11-rc1-2' of git://oss.sgi.com/xfs/xfs
[~andy/linux] / fs / xfs / xfs_iomap.c
index 8f8aaee7f3791457c9ec43ea46927bc05f624f04..6a7096422295d1d821f1e0bab397041c42f53de1 100644 (file)
@@ -283,6 +283,15 @@ xfs_iomap_eof_want_preallocate(
        if (offset + count <= XFS_ISIZE(ip))
                return 0;
 
+       /*
+        * If the file is smaller than the minimum prealloc and we are using
+        * dynamic preallocation, don't do any preallocation at all as it is
+        * likely this is the only write to the file that is going to be done.
+        */
+       if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) &&
+           XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_writeio_blocks))
+               return 0;
+
        /*
         * If there are any real blocks past eof, then don't
         * do any speculative allocation.
@@ -345,6 +354,10 @@ xfs_iomap_eof_prealloc_initial_size(
        if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
                return 0;
 
+       /* If the file is small, then use the minimum prealloc */
+       if (XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_dalign))
+               return 0;
+
        /*
         * As we write multiple pages, the offset will always align to the
         * start of a page and hence point to a hole at EOF. i.e. if the size is