diff options
| -rw-r--r-- | Documentation/filesystems/xfs.txt | 17 | ||||
| -rw-r--r-- | fs/xfs/kmem.c | 10 | ||||
| -rw-r--r-- | fs/xfs/kmem.h | 5 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_bmap.c | 6 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_bmap.h | 33 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_format.h | 10 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_fs.h (renamed from fs/xfs/xfs_fs.h) | 0 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_symlink_remote.c | 2 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_types.h (renamed from fs/xfs/xfs_types.h) | 0 | ||||
| -rw-r--r-- | fs/xfs/xfs_aops.c | 149 | ||||
| -rw-r--r-- | fs/xfs/xfs_aops.h | 3 | ||||
| -rw-r--r-- | fs/xfs/xfs_bmap_util.h | 37 | ||||
| -rw-r--r-- | fs/xfs/xfs_buf_item.c | 6 | ||||
| -rw-r--r-- | fs/xfs/xfs_dquot.h | 2 | ||||
| -rw-r--r-- | fs/xfs/xfs_file.c | 64 | ||||
| -rw-r--r-- | fs/xfs/xfs_inode.c | 136 | ||||
| -rw-r--r-- | fs/xfs/xfs_inode.h | 11 | ||||
| -rw-r--r-- | fs/xfs/xfs_ioctl.c | 50 | ||||
| -rw-r--r-- | fs/xfs/xfs_ioctl32.c | 2 | ||||
| -rw-r--r-- | fs/xfs/xfs_iomap.c | 2 | ||||
| -rw-r--r-- | fs/xfs/xfs_iomap.h | 2 | ||||
| -rw-r--r-- | fs/xfs/xfs_iops.c | 21 | ||||
| -rw-r--r-- | fs/xfs/xfs_log.c | 10 | ||||
| -rw-r--r-- | fs/xfs/xfs_super.c | 2 | ||||
| -rw-r--r-- | fs/xfs/xfs_sysctl.c | 18 | ||||
| -rw-r--r-- | fs/xfs/xfs_trans.c | 1 |
26 files changed, 348 insertions, 251 deletions
diff --git a/Documentation/filesystems/xfs.txt b/Documentation/filesystems/xfs.txt index 2e5684596090..0bfafe108357 100644 --- a/Documentation/filesystems/xfs.txt +++ b/Documentation/filesystems/xfs.txt | |||
| @@ -349,16 +349,13 @@ The following sysctls are available for the XFS filesystem: | |||
| 349 | Deprecated Sysctls | 349 | Deprecated Sysctls |
| 350 | ================== | 350 | ================== |
| 351 | 351 | ||
| 352 | fs.xfs.xfsbufd_centisecs (Min: 50 Default: 100 Max: 3000) | 352 | None at present. |
| 353 | Dirty metadata is now tracked by the log subsystem and | ||
| 354 | flushing is driven by log space and idling demands. The | ||
| 355 | xfsbufd no longer exists, so this syctl does nothing. | ||
| 356 | 353 | ||
| 357 | Due for removal in 3.14. | ||
| 358 | 354 | ||
| 359 | fs.xfs.age_buffer_centisecs (Min: 100 Default: 1500 Max: 720000) | 355 | Removed Sysctls |
| 360 | Dirty metadata is now tracked by the log subsystem and | 356 | =============== |
| 361 | flushing is driven by log space and idling demands. The | ||
| 362 | xfsbufd no longer exists, so this syctl does nothing. | ||
| 363 | 357 | ||
| 364 | Due for removal in 3.14. | 358 | Name Removed |
| 359 | ---- ------- | ||
| 360 | fs.xfs.xfsbufd_centisec v3.20 | ||
| 361 | fs.xfs.age_buffer_centisecs v3.20 | ||
diff --git a/fs/xfs/kmem.c b/fs/xfs/kmem.c index 53e95b2a1369..a7a3a63bb360 100644 --- a/fs/xfs/kmem.c +++ b/fs/xfs/kmem.c | |||
| @@ -91,16 +91,6 @@ kmem_zalloc_large(size_t size, xfs_km_flags_t flags) | |||
| 91 | return ptr; | 91 | return ptr; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | void | ||
| 95 | kmem_free(const void *ptr) | ||
| 96 | { | ||
| 97 | if (!is_vmalloc_addr(ptr)) { | ||
| 98 | kfree(ptr); | ||
| 99 | } else { | ||
| 100 | vfree(ptr); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | void * | 94 | void * |
| 105 | kmem_realloc(const void *ptr, size_t newsize, size_t oldsize, | 95 | kmem_realloc(const void *ptr, size_t newsize, size_t oldsize, |
| 106 | xfs_km_flags_t flags) | 96 | xfs_km_flags_t flags) |
diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h index 64db0e53edea..cc6b768fc068 100644 --- a/fs/xfs/kmem.h +++ b/fs/xfs/kmem.h | |||
| @@ -63,7 +63,10 @@ kmem_flags_convert(xfs_km_flags_t flags) | |||
| 63 | extern void *kmem_alloc(size_t, xfs_km_flags_t); | 63 | extern void *kmem_alloc(size_t, xfs_km_flags_t); |
| 64 | extern void *kmem_zalloc_large(size_t size, xfs_km_flags_t); | 64 | extern void *kmem_zalloc_large(size_t size, xfs_km_flags_t); |
| 65 | extern void *kmem_realloc(const void *, size_t, size_t, xfs_km_flags_t); | 65 | extern void *kmem_realloc(const void *, size_t, size_t, xfs_km_flags_t); |
| 66 | extern void kmem_free(const void *); | 66 | static inline void kmem_free(const void *ptr) |
| 67 | { | ||
| 68 | kvfree(ptr); | ||
| 69 | } | ||
| 67 | 70 | ||
| 68 | 71 | ||
| 69 | extern void *kmem_zalloc_greedy(size_t *, size_t, size_t); | 72 | extern void *kmem_zalloc_greedy(size_t *, size_t, size_t); |
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 63a5bb9113ee..61ec015dca16 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c | |||
| @@ -973,7 +973,11 @@ xfs_bmap_local_to_extents( | |||
| 973 | *firstblock = args.fsbno; | 973 | *firstblock = args.fsbno; |
| 974 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); | 974 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); |
| 975 | 975 | ||
| 976 | /* initialise the block and copy the data */ | 976 | /* |
| 977 | * Initialise the block and copy the data | ||
| 978 | * | ||
| 979 | * Note: init_fn must set the buffer log item type correctly! | ||
| 980 | */ | ||
| 977 | init_fn(tp, bp, ip, ifp); | 981 | init_fn(tp, bp, ip, ifp); |
| 978 | 982 | ||
| 979 | /* account for the change in fork size and log everything */ | 983 | /* account for the change in fork size and log everything */ |
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index 44db6db86402..b9d8a499d2c4 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h | |||
| @@ -28,6 +28,37 @@ struct xfs_trans; | |||
| 28 | extern kmem_zone_t *xfs_bmap_free_item_zone; | 28 | extern kmem_zone_t *xfs_bmap_free_item_zone; |
| 29 | 29 | ||
| 30 | /* | 30 | /* |
| 31 | * Argument structure for xfs_bmap_alloc. | ||
| 32 | */ | ||
| 33 | struct xfs_bmalloca { | ||
| 34 | xfs_fsblock_t *firstblock; /* i/o first block allocated */ | ||
| 35 | struct xfs_bmap_free *flist; /* bmap freelist */ | ||
| 36 | struct xfs_trans *tp; /* transaction pointer */ | ||
| 37 | struct xfs_inode *ip; /* incore inode pointer */ | ||
| 38 | struct xfs_bmbt_irec prev; /* extent before the new one */ | ||
| 39 | struct xfs_bmbt_irec got; /* extent after, or delayed */ | ||
| 40 | |||
| 41 | xfs_fileoff_t offset; /* offset in file filling in */ | ||
| 42 | xfs_extlen_t length; /* i/o length asked/allocated */ | ||
| 43 | xfs_fsblock_t blkno; /* starting block of new extent */ | ||
| 44 | |||
| 45 | struct xfs_btree_cur *cur; /* btree cursor */ | ||
| 46 | xfs_extnum_t idx; /* current extent index */ | ||
| 47 | int nallocs;/* number of extents alloc'd */ | ||
| 48 | int logflags;/* flags for transaction logging */ | ||
| 49 | |||
| 50 | xfs_extlen_t total; /* total blocks needed for xaction */ | ||
| 51 | xfs_extlen_t minlen; /* minimum allocation size (blocks) */ | ||
| 52 | xfs_extlen_t minleft; /* amount must be left after alloc */ | ||
| 53 | bool eof; /* set if allocating past last extent */ | ||
| 54 | bool wasdel; /* replacing a delayed allocation */ | ||
| 55 | bool userdata;/* set if is user data */ | ||
| 56 | bool aeof; /* allocated space at eof */ | ||
| 57 | bool conv; /* overwriting unwritten extents */ | ||
| 58 | int flags; | ||
| 59 | }; | ||
| 60 | |||
| 61 | /* | ||
| 31 | * List of extents to be free "later". | 62 | * List of extents to be free "later". |
| 32 | * The list is kept sorted on xbf_startblock. | 63 | * The list is kept sorted on xbf_startblock. |
| 33 | */ | 64 | */ |
| @@ -149,6 +180,8 @@ void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork); | |||
| 149 | void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len, | 180 | void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len, |
| 150 | struct xfs_bmap_free *flist, struct xfs_mount *mp); | 181 | struct xfs_bmap_free *flist, struct xfs_mount *mp); |
| 151 | void xfs_bmap_cancel(struct xfs_bmap_free *flist); | 182 | void xfs_bmap_cancel(struct xfs_bmap_free *flist); |
| 183 | int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, | ||
| 184 | int *committed); | ||
| 152 | void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); | 185 | void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); |
| 153 | int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, | 186 | int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, |
| 154 | xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); | 187 | xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); |
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 749c86102794..8eb718979383 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h | |||
| @@ -307,8 +307,8 @@ typedef enum { | |||
| 307 | #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) | 307 | #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) |
| 308 | #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) | 308 | #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) |
| 309 | #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) | 309 | #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) |
| 310 | #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) | 310 | #define XFS_SB_FEATURES2 (XFS_SB_MVAL(FEATURES2) | \ |
| 311 | #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) | 311 | XFS_SB_MVAL(BAD_FEATURES2)) |
| 312 | #define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT) | 312 | #define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT) |
| 313 | #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT) | 313 | #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT) |
| 314 | #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) | 314 | #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) |
| @@ -322,9 +322,9 @@ typedef enum { | |||
| 322 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ | 322 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ |
| 323 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ | 323 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ |
| 324 | XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ | 324 | XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ |
| 325 | XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \ | 325 | XFS_SB_FEATURES_COMPAT | XFS_SB_FEATURES_RO_COMPAT | \ |
| 326 | XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \ | 326 | XFS_SB_FEATURES_INCOMPAT | XFS_SB_FEATURES_LOG_INCOMPAT | \ |
| 327 | XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO) | 327 | XFS_SB_PQUOTINO) |
| 328 | 328 | ||
| 329 | 329 | ||
| 330 | /* | 330 | /* |
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 18dc721ca19f..18dc721ca19f 100644 --- a/fs/xfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h | |||
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c index c80c5236c3da..e7e26bd6468f 100644 --- a/fs/xfs/libxfs/xfs_symlink_remote.c +++ b/fs/xfs/libxfs/xfs_symlink_remote.c | |||
| @@ -178,6 +178,8 @@ xfs_symlink_local_to_remote( | |||
| 178 | struct xfs_mount *mp = ip->i_mount; | 178 | struct xfs_mount *mp = ip->i_mount; |
| 179 | char *buf; | 179 | char *buf; |
| 180 | 180 | ||
| 181 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SYMLINK_BUF); | ||
| 182 | |||
| 181 | if (!xfs_sb_version_hascrc(&mp->m_sb)) { | 183 | if (!xfs_sb_version_hascrc(&mp->m_sb)) { |
| 182 | bp->b_ops = NULL; | 184 | bp->b_ops = NULL; |
| 183 | memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); | 185 | memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); |
diff --git a/fs/xfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h index b79dc66b2ecd..b79dc66b2ecd 100644 --- a/fs/xfs/xfs_types.h +++ b/fs/xfs/libxfs/xfs_types.h | |||
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 18e2f3bbae5e..3a9b7a1b8704 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c | |||
| @@ -135,30 +135,22 @@ xfs_setfilesize_trans_alloc( | |||
| 135 | */ | 135 | */ |
| 136 | STATIC int | 136 | STATIC int |
| 137 | xfs_setfilesize( | 137 | xfs_setfilesize( |
| 138 | struct xfs_ioend *ioend) | 138 | struct xfs_inode *ip, |
| 139 | struct xfs_trans *tp, | ||
| 140 | xfs_off_t offset, | ||
| 141 | size_t size) | ||
| 139 | { | 142 | { |
| 140 | struct xfs_inode *ip = XFS_I(ioend->io_inode); | ||
| 141 | struct xfs_trans *tp = ioend->io_append_trans; | ||
| 142 | xfs_fsize_t isize; | 143 | xfs_fsize_t isize; |
| 143 | 144 | ||
| 144 | /* | ||
| 145 | * The transaction may have been allocated in the I/O submission thread, | ||
| 146 | * thus we need to mark ourselves as beeing in a transaction manually. | ||
| 147 | * Similarly for freeze protection. | ||
| 148 | */ | ||
| 149 | current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); | ||
| 150 | rwsem_acquire_read(&VFS_I(ip)->i_sb->s_writers.lock_map[SB_FREEZE_FS-1], | ||
| 151 | 0, 1, _THIS_IP_); | ||
| 152 | |||
| 153 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 145 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
| 154 | isize = xfs_new_eof(ip, ioend->io_offset + ioend->io_size); | 146 | isize = xfs_new_eof(ip, offset + size); |
| 155 | if (!isize) { | 147 | if (!isize) { |
| 156 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 148 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
| 157 | xfs_trans_cancel(tp, 0); | 149 | xfs_trans_cancel(tp, 0); |
| 158 | return 0; | 150 | return 0; |
| 159 | } | 151 | } |
| 160 | 152 | ||
| 161 | trace_xfs_setfilesize(ip, ioend->io_offset, ioend->io_size); | 153 | trace_xfs_setfilesize(ip, offset, size); |
| 162 | 154 | ||
| 163 | ip->i_d.di_size = isize; | 155 | ip->i_d.di_size = isize; |
| 164 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | 156 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); |
| @@ -167,6 +159,25 @@ xfs_setfilesize( | |||
| 167 | return xfs_trans_commit(tp, 0); | 159 | return xfs_trans_commit(tp, 0); |
| 168 | } | 160 | } |
| 169 | 161 | ||
| 162 | STATIC int | ||
| 163 | xfs_setfilesize_ioend( | ||
| 164 | struct xfs_ioend *ioend) | ||
| 165 | { | ||
| 166 | struct xfs_inode *ip = XFS_I(ioend->io_inode); | ||
| 167 | struct xfs_trans *tp = ioend->io_append_trans; | ||
| 168 | |||
| 169 | /* | ||
| 170 | * The transaction may have been allocated in the I/O submission thread, | ||
| 171 | * thus we need to mark ourselves as being in a transaction manually. | ||
| 172 | * Similarly for freeze protection. | ||
| 173 | */ | ||
| 174 | current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); | ||
| 175 | rwsem_acquire_read(&VFS_I(ip)->i_sb->s_writers.lock_map[SB_FREEZE_FS-1], | ||
| 176 | 0, 1, _THIS_IP_); | ||
| 177 | |||
| 178 | return xfs_setfilesize(ip, tp, ioend->io_offset, ioend->io_size); | ||
| 179 | } | ||
| 180 | |||
| 170 | /* | 181 | /* |
| 171 | * Schedule IO completion handling on the final put of an ioend. | 182 | * Schedule IO completion handling on the final put of an ioend. |
| 172 | * | 183 | * |
| @@ -182,8 +193,7 @@ xfs_finish_ioend( | |||
| 182 | 193 | ||
| 183 | if (ioend->io_type == XFS_IO_UNWRITTEN) | 194 | if (ioend->io_type == XFS_IO_UNWRITTEN) |
| 184 | queue_work(mp->m_unwritten_workqueue, &ioend->io_work); | 195 | queue_work(mp->m_unwritten_workqueue, &ioend->io_work); |
| 185 | else if (ioend->io_append_trans || | 196 | else if (ioend->io_append_trans) |
| 186 | (ioend->io_isdirect && xfs_ioend_is_append(ioend))) | ||
| 187 | queue_work(mp->m_data_workqueue, &ioend->io_work); | 197 | queue_work(mp->m_data_workqueue, &ioend->io_work); |
| 188 | else | 198 | else |
| 189 | xfs_destroy_ioend(ioend); | 199 | xfs_destroy_ioend(ioend); |
| @@ -215,22 +225,8 @@ xfs_end_io( | |||
| 215 | if (ioend->io_type == XFS_IO_UNWRITTEN) { | 225 | if (ioend->io_type == XFS_IO_UNWRITTEN) { |
| 216 | error = xfs_iomap_write_unwritten(ip, ioend->io_offset, | 226 | error = xfs_iomap_write_unwritten(ip, ioend->io_offset, |
| 217 | ioend->io_size); | 227 | ioend->io_size); |
| 218 | } else if (ioend->io_isdirect && xfs_ioend_is_append(ioend)) { | ||
| 219 | /* | ||
| 220 | * For direct I/O we do not know if we need to allocate blocks | ||
| 221 | * or not so we can't preallocate an append transaction as that | ||
| 222 | * results in nested reservations and log space deadlocks. Hence | ||
| 223 | * allocate the transaction here. While this is sub-optimal and | ||
| 224 | * can block IO completion for some time, we're stuck with doing | ||
| 225 | * it this way until we can pass the ioend to the direct IO | ||
| 226 | * allocation callbacks and avoid nesting that way. | ||
| 227 | */ | ||
| 228 | error = xfs_setfilesize_trans_alloc(ioend); | ||
| 229 | if (error) | ||
| 230 | goto done; | ||
| 231 | error = xfs_setfilesize(ioend); | ||
| 232 | } else if (ioend->io_append_trans) { | 228 | } else if (ioend->io_append_trans) { |
| 233 | error = xfs_setfilesize(ioend); | 229 | error = xfs_setfilesize_ioend(ioend); |
| 234 | } else { | 230 | } else { |
| 235 | ASSERT(!xfs_ioend_is_append(ioend)); | 231 | ASSERT(!xfs_ioend_is_append(ioend)); |
| 236 | } | 232 | } |
| @@ -242,17 +238,6 @@ done: | |||
| 242 | } | 238 | } |
| 243 | 239 | ||
| 244 | /* | 240 | /* |
| 245 | * Call IO completion handling in caller context on the final put of an ioend. | ||
| 246 | */ | ||
| 247 | STATIC void | ||
| 248 | xfs_finish_ioend_sync( | ||
| 249 | struct xfs_ioend *ioend) | ||
| 250 | { | ||
| 251 | if (atomic_dec_and_test(&ioend->io_remaining)) | ||
| 252 | xfs_end_io(&ioend->io_work); | ||
| 253 | } | ||
| 254 | |||
| 255 | /* | ||
| 256 | * Allocate and initialise an IO completion structure. | 241 | * Allocate and initialise an IO completion structure. |
| 257 | * We need to track unwritten extent write completion here initially. | 242 | * We need to track unwritten extent write completion here initially. |
| 258 | * We'll need to extend this for updating the ondisk inode size later | 243 | * We'll need to extend this for updating the ondisk inode size later |
| @@ -273,7 +258,6 @@ xfs_alloc_ioend( | |||
| 273 | * all the I/O from calling the completion routine too early. | 258 | * all the I/O from calling the completion routine too early. |
| 274 | */ | 259 | */ |
| 275 | atomic_set(&ioend->io_remaining, 1); | 260 | atomic_set(&ioend->io_remaining, 1); |
| 276 | ioend->io_isdirect = 0; | ||
| 277 | ioend->io_error = 0; | 261 | ioend->io_error = 0; |
| 278 | ioend->io_list = NULL; | 262 | ioend->io_list = NULL; |
| 279 | ioend->io_type = type; | 263 | ioend->io_type = type; |
| @@ -1459,11 +1443,7 @@ xfs_get_blocks_direct( | |||
| 1459 | * | 1443 | * |
| 1460 | * If the private argument is non-NULL __xfs_get_blocks signals us that we | 1444 | * If the private argument is non-NULL __xfs_get_blocks signals us that we |
| 1461 | * need to issue a transaction to convert the range from unwritten to written | 1445 | * need to issue a transaction to convert the range from unwritten to written |
| 1462 | * extents. In case this is regular synchronous I/O we just call xfs_end_io | 1446 | * extents. |
| 1463 | * to do this and we are done. But in case this was a successful AIO | ||
| 1464 | * request this handler is called from interrupt context, from which we | ||
| 1465 | * can't start transactions. In that case offload the I/O completion to | ||
| 1466 | * the workqueues we also use for buffered I/O completion. | ||
| 1467 | */ | 1447 | */ |
| 1468 | STATIC void | 1448 | STATIC void |
| 1469 | xfs_end_io_direct_write( | 1449 | xfs_end_io_direct_write( |
| @@ -1472,7 +1452,12 @@ xfs_end_io_direct_write( | |||
| 1472 | ssize_t size, | 1452 | ssize_t size, |
| 1473 | void *private) | 1453 | void *private) |
| 1474 | { | 1454 | { |
| 1475 | struct xfs_ioend *ioend = iocb->private; | 1455 | struct inode *inode = file_inode(iocb->ki_filp); |
| 1456 | struct xfs_inode *ip = XFS_I(inode); | ||
| 1457 | struct xfs_mount *mp = ip->i_mount; | ||
| 1458 | |||
| 1459 | if (XFS_FORCED_SHUTDOWN(mp)) | ||
| 1460 | return; | ||
| 1476 | 1461 | ||
| 1477 | /* | 1462 | /* |
| 1478 | * While the generic direct I/O code updates the inode size, it does | 1463 | * While the generic direct I/O code updates the inode size, it does |
| @@ -1480,22 +1465,33 @@ xfs_end_io_direct_write( | |||
| 1480 | * end_io handler thinks the on-disk size is outside the in-core | 1465 | * end_io handler thinks the on-disk size is outside the in-core |
| 1481 | * size. To prevent this just update it a little bit earlier here. | 1466 | * size. To prevent this just update it a little bit earlier here. |
| 1482 | */ | 1467 | */ |
| 1483 | if (offset + size > i_size_read(ioend->io_inode)) | 1468 | if (offset + size > i_size_read(inode)) |
| 1484 | i_size_write(ioend->io_inode, offset + size); | 1469 | i_size_write(inode, offset + size); |
| 1485 | 1470 | ||
| 1486 | /* | 1471 | /* |
| 1487 | * blockdev_direct_IO can return an error even after the I/O | 1472 | * For direct I/O we do not know if we need to allocate blocks or not, |
| 1488 | * completion handler was called. Thus we need to protect | 1473 | * so we can't preallocate an append transaction, as that results in |
| 1489 | * against double-freeing. | 1474 | * nested reservations and log space deadlocks. Hence allocate the |
| 1475 | * transaction here. While this is sub-optimal and can block IO | ||
| 1476 | * completion for some time, we're stuck with doing it this way until | ||
| 1477 | * we can pass the ioend to the direct IO allocation callbacks and | ||
| 1478 | * avoid nesting that way. | ||
| 1490 | */ | 1479 | */ |
| 1491 | iocb->private = NULL; | 1480 | if (private && size > 0) { |
| 1492 | 1481 | xfs_iomap_write_unwritten(ip, offset, size); | |
| 1493 | ioend->io_offset = offset; | 1482 | } else if (offset + size > ip->i_d.di_size) { |
| 1494 | ioend->io_size = size; | 1483 | struct xfs_trans *tp; |
| 1495 | if (private && size > 0) | 1484 | int error; |
| 1496 | ioend->io_type = XFS_IO_UNWRITTEN; | 1485 | |
| 1486 | tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); | ||
| 1487 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0); | ||
| 1488 | if (error) { | ||
| 1489 | xfs_trans_cancel(tp, 0); | ||
| 1490 | return; | ||
| 1491 | } | ||
| 1497 | 1492 | ||
| 1498 | xfs_finish_ioend_sync(ioend); | 1493 | xfs_setfilesize(ip, tp, offset, size); |
| 1494 | } | ||
| 1499 | } | 1495 | } |
| 1500 | 1496 | ||
| 1501 | STATIC ssize_t | 1497 | STATIC ssize_t |
| @@ -1507,39 +1503,16 @@ xfs_vm_direct_IO( | |||
| 1507 | { | 1503 | { |
| 1508 | struct inode *inode = iocb->ki_filp->f_mapping->host; | 1504 | struct inode *inode = iocb->ki_filp->f_mapping->host; |
| 1509 | struct block_device *bdev = xfs_find_bdev_for_inode(inode); | 1505 | struct block_device *bdev = xfs_find_bdev_for_inode(inode); |
| 1510 | struct xfs_ioend *ioend = NULL; | ||
| 1511 | ssize_t ret; | ||
| 1512 | 1506 | ||
| 1513 | if (rw & WRITE) { | 1507 | if (rw & WRITE) { |
| 1514 | size_t size = iov_iter_count(iter); | 1508 | return __blockdev_direct_IO(rw, iocb, inode, bdev, iter, |
| 1515 | |||
| 1516 | /* | ||
| 1517 | * We cannot preallocate a size update transaction here as we | ||
| 1518 | * don't know whether allocation is necessary or not. Hence we | ||
| 1519 | * can only tell IO completion that one is necessary if we are | ||
| 1520 | * not doing unwritten extent conversion. | ||
| 1521 | */ | ||
| 1522 | iocb->private = ioend = xfs_alloc_ioend(inode, XFS_IO_DIRECT); | ||
| 1523 | if (offset + size > XFS_I(inode)->i_d.di_size) | ||
| 1524 | ioend->io_isdirect = 1; | ||
| 1525 | |||
| 1526 | ret = __blockdev_direct_IO(rw, iocb, inode, bdev, iter, | ||
| 1527 | offset, xfs_get_blocks_direct, | 1509 | offset, xfs_get_blocks_direct, |
| 1528 | xfs_end_io_direct_write, NULL, | 1510 | xfs_end_io_direct_write, NULL, |
| 1529 | DIO_ASYNC_EXTEND); | 1511 | DIO_ASYNC_EXTEND); |
| 1530 | if (ret != -EIOCBQUEUED && iocb->private) | ||
| 1531 | goto out_destroy_ioend; | ||
| 1532 | } else { | ||
| 1533 | ret = __blockdev_direct_IO(rw, iocb, inode, bdev, iter, | ||
| 1534 | offset, xfs_get_blocks_direct, | ||
| 1535 | NULL, NULL, 0); | ||
| 1536 | } | 1512 | } |
| 1537 | 1513 | return __blockdev_direct_IO(rw, iocb, inode, bdev, iter, | |
| 1538 | return ret; | 1514 | offset, xfs_get_blocks_direct, |
| 1539 | 1515 | NULL, NULL, 0); | |
| 1540 | out_destroy_ioend: | ||
| 1541 | xfs_destroy_ioend(ioend); | ||
| 1542 | return ret; | ||
| 1543 | } | 1516 | } |
| 1544 | 1517 | ||
| 1545 | /* | 1518 | /* |
diff --git a/fs/xfs/xfs_aops.h b/fs/xfs/xfs_aops.h index f94dd459dff9..ac644e0137a4 100644 --- a/fs/xfs/xfs_aops.h +++ b/fs/xfs/xfs_aops.h | |||
| @@ -24,14 +24,12 @@ extern mempool_t *xfs_ioend_pool; | |||
| 24 | * Types of I/O for bmap clustering and I/O completion tracking. | 24 | * Types of I/O for bmap clustering and I/O completion tracking. |
| 25 | */ | 25 | */ |
| 26 | enum { | 26 | enum { |
| 27 | XFS_IO_DIRECT = 0, /* special case for direct I/O ioends */ | ||
| 28 | XFS_IO_DELALLOC, /* covers delalloc region */ | 27 | XFS_IO_DELALLOC, /* covers delalloc region */ |
| 29 | XFS_IO_UNWRITTEN, /* covers allocated but uninitialized data */ | 28 | XFS_IO_UNWRITTEN, /* covers allocated but uninitialized data */ |
| 30 | XFS_IO_OVERWRITE, /* covers already allocated extent */ | 29 | XFS_IO_OVERWRITE, /* covers already allocated extent */ |
| 31 | }; | 30 | }; |
| 32 | 31 | ||
| 33 | #define XFS_IO_TYPES \ | 32 | #define XFS_IO_TYPES \ |
| 34 | { 0, "" }, \ | ||
| 35 | { XFS_IO_DELALLOC, "delalloc" }, \ | 33 | { XFS_IO_DELALLOC, "delalloc" }, \ |
| 36 | { XFS_IO_UNWRITTEN, "unwritten" }, \ | 34 | { XFS_IO_UNWRITTEN, "unwritten" }, \ |
| 37 | { XFS_IO_OVERWRITE, "overwrite" } | 35 | { XFS_IO_OVERWRITE, "overwrite" } |
| @@ -45,7 +43,6 @@ typedef struct xfs_ioend { | |||
| 45 | unsigned int io_type; /* delalloc / unwritten */ | 43 | unsigned int io_type; /* delalloc / unwritten */ |
| 46 | int io_error; /* I/O error code */ | 44 | int io_error; /* I/O error code */ |
| 47 | atomic_t io_remaining; /* hold count */ | 45 | atomic_t io_remaining; /* hold count */ |
| 48 | unsigned int io_isdirect : 1;/* direct I/O */ | ||
| 49 | struct inode *io_inode; /* file being written to */ | 46 | struct inode *io_inode; /* file being written to */ |
| 50 | struct buffer_head *io_buffer_head;/* buffer linked list head */ | 47 | struct buffer_head *io_buffer_head;/* buffer linked list head */ |
| 51 | struct buffer_head *io_buffer_tail;/* buffer linked list tail */ | 48 | struct buffer_head *io_buffer_tail;/* buffer linked list tail */ |
diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h index 2fdb72d2c908..736429a72a12 100644 --- a/fs/xfs/xfs_bmap_util.h +++ b/fs/xfs/xfs_bmap_util.h | |||
| @@ -26,43 +26,8 @@ struct xfs_ifork; | |||
| 26 | struct xfs_inode; | 26 | struct xfs_inode; |
| 27 | struct xfs_mount; | 27 | struct xfs_mount; |
| 28 | struct xfs_trans; | 28 | struct xfs_trans; |
| 29 | struct xfs_bmalloca; | ||
| 29 | 30 | ||
| 30 | /* | ||
| 31 | * Argument structure for xfs_bmap_alloc. | ||
| 32 | */ | ||
| 33 | struct xfs_bmalloca { | ||
| 34 | xfs_fsblock_t *firstblock; /* i/o first block allocated */ | ||
| 35 | struct xfs_bmap_free *flist; /* bmap freelist */ | ||
| 36 | struct xfs_trans *tp; /* transaction pointer */ | ||
| 37 | struct xfs_inode *ip; /* incore inode pointer */ | ||
| 38 | struct xfs_bmbt_irec prev; /* extent before the new one */ | ||
| 39 | struct xfs_bmbt_irec got; /* extent after, or delayed */ | ||
| 40 | |||
| 41 | xfs_fileoff_t offset; /* offset in file filling in */ | ||
| 42 | xfs_extlen_t length; /* i/o length asked/allocated */ | ||
| 43 | xfs_fsblock_t blkno; /* starting block of new extent */ | ||
| 44 | |||
| 45 | struct xfs_btree_cur *cur; /* btree cursor */ | ||
| 46 | xfs_extnum_t idx; /* current extent index */ | ||
| 47 | int nallocs;/* number of extents alloc'd */ | ||
| 48 | int logflags;/* flags for transaction logging */ | ||
| 49 | |||
| 50 | xfs_extlen_t total; /* total blocks needed for xaction */ | ||
| 51 | xfs_extlen_t minlen; /* minimum allocation size (blocks) */ | ||
| 52 | xfs_extlen_t minleft; /* amount must be left after alloc */ | ||
| 53 | bool eof; /* set if allocating past last extent */ | ||
| 54 | bool wasdel; /* replacing a delayed allocation */ | ||
| 55 | bool userdata;/* set if is user data */ | ||
| 56 | bool aeof; /* allocated space at eof */ | ||
| 57 | bool conv; /* overwriting unwritten extents */ | ||
| 58 | int flags; | ||
| 59 | struct completion *done; | ||
| 60 | struct work_struct work; | ||
| 61 | int result; | ||
| 62 | }; | ||
| 63 | |||
| 64 | int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, | ||
| 65 | int *committed); | ||
| 66 | int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); | 31 | int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); |
| 67 | int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff, | 32 | int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff, |
| 68 | int whichfork, int *eof); | 33 | int whichfork, int *eof); |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 3f9bd58edec7..507d96a57ac7 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
| @@ -319,6 +319,10 @@ xfs_buf_item_format( | |||
| 319 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 319 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 320 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || | 320 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || |
| 321 | (bip->bli_flags & XFS_BLI_STALE)); | 321 | (bip->bli_flags & XFS_BLI_STALE)); |
| 322 | ASSERT((bip->bli_flags & XFS_BLI_STALE) || | ||
| 323 | (xfs_blft_from_flags(&bip->__bli_format) > XFS_BLFT_UNKNOWN_BUF | ||
| 324 | && xfs_blft_from_flags(&bip->__bli_format) < XFS_BLFT_MAX_BUF)); | ||
| 325 | |||
| 322 | 326 | ||
| 323 | /* | 327 | /* |
| 324 | * If it is an inode buffer, transfer the in-memory state to the | 328 | * If it is an inode buffer, transfer the in-memory state to the |
| @@ -535,7 +539,7 @@ xfs_buf_item_push( | |||
| 535 | if ((bp->b_flags & XBF_WRITE_FAIL) && | 539 | if ((bp->b_flags & XBF_WRITE_FAIL) && |
| 536 | ___ratelimit(&xfs_buf_write_fail_rl_state, "XFS:")) { | 540 | ___ratelimit(&xfs_buf_write_fail_rl_state, "XFS:")) { |
| 537 | xfs_warn(bp->b_target->bt_mount, | 541 | xfs_warn(bp->b_target->bt_mount, |
| 538 | "Detected failing async write on buffer block 0x%llx. Retrying async write.\n", | 542 | "Detected failing async write on buffer block 0x%llx. Retrying async write.", |
| 539 | (long long)bp->b_bn); | 543 | (long long)bp->b_bn); |
| 540 | } | 544 | } |
| 541 | 545 | ||
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index c24c67e22a2a..2f536f33cd26 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h | |||
| @@ -86,7 +86,7 @@ static inline void xfs_dqflock(xfs_dquot_t *dqp) | |||
| 86 | wait_for_completion(&dqp->q_flush); | 86 | wait_for_completion(&dqp->q_flush); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | static inline int xfs_dqflock_nowait(xfs_dquot_t *dqp) | 89 | static inline bool xfs_dqflock_nowait(xfs_dquot_t *dqp) |
| 90 | { | 90 | { |
| 91 | return try_wait_for_completion(&dqp->q_flush); | 91 | return try_wait_for_completion(&dqp->q_flush); |
| 92 | } | 92 | } |
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 13e974e6a889..712d312d8e3e 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
| @@ -127,6 +127,42 @@ xfs_iozero( | |||
| 127 | return (-status); | 127 | return (-status); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | int | ||
| 131 | xfs_update_prealloc_flags( | ||
| 132 | struct xfs_inode *ip, | ||
| 133 | enum xfs_prealloc_flags flags) | ||
| 134 | { | ||
| 135 | struct xfs_trans *tp; | ||
| 136 | int error; | ||
| 137 | |||
| 138 | tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_WRITEID); | ||
| 139 | error = xfs_trans_reserve(tp, &M_RES(ip->i_mount)->tr_writeid, 0, 0); | ||
| 140 | if (error) { | ||
| 141 | xfs_trans_cancel(tp, 0); | ||
| 142 | return error; | ||
| 143 | } | ||
| 144 | |||
| 145 | xfs_ilock(ip, XFS_ILOCK_EXCL); | ||
| 146 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | ||
| 147 | |||
| 148 | if (!(flags & XFS_PREALLOC_INVISIBLE)) { | ||
| 149 | ip->i_d.di_mode &= ~S_ISUID; | ||
| 150 | if (ip->i_d.di_mode & S_IXGRP) | ||
| 151 | ip->i_d.di_mode &= ~S_ISGID; | ||
| 152 | xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); | ||
| 153 | } | ||
| 154 | |||
| 155 | if (flags & XFS_PREALLOC_SET) | ||
| 156 | ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC; | ||
| 157 | if (flags & XFS_PREALLOC_CLEAR) | ||
| 158 | ip->i_d.di_flags &= ~XFS_DIFLAG_PREALLOC; | ||
| 159 | |||
| 160 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | ||
| 161 | if (flags & XFS_PREALLOC_SYNC) | ||
| 162 | xfs_trans_set_sync(tp); | ||
| 163 | return xfs_trans_commit(tp, 0); | ||
| 164 | } | ||
| 165 | |||
| 130 | /* | 166 | /* |
| 131 | * Fsync operations on directories are much simpler than on regular files, | 167 | * Fsync operations on directories are much simpler than on regular files, |
| 132 | * as there is no file data to flush, and thus also no need for explicit | 168 | * as there is no file data to flush, and thus also no need for explicit |
| @@ -784,8 +820,8 @@ xfs_file_fallocate( | |||
| 784 | { | 820 | { |
| 785 | struct inode *inode = file_inode(file); | 821 | struct inode *inode = file_inode(file); |
| 786 | struct xfs_inode *ip = XFS_I(inode); | 822 | struct xfs_inode *ip = XFS_I(inode); |
| 787 | struct xfs_trans *tp; | ||
| 788 | long error; | 823 | long error; |
| 824 | enum xfs_prealloc_flags flags = 0; | ||
| 789 | loff_t new_size = 0; | 825 | loff_t new_size = 0; |
| 790 | 826 | ||
| 791 | if (!S_ISREG(inode->i_mode)) | 827 | if (!S_ISREG(inode->i_mode)) |
| @@ -822,6 +858,8 @@ xfs_file_fallocate( | |||
| 822 | if (error) | 858 | if (error) |
| 823 | goto out_unlock; | 859 | goto out_unlock; |
| 824 | } else { | 860 | } else { |
| 861 | flags |= XFS_PREALLOC_SET; | ||
| 862 | |||
| 825 | if (!(mode & FALLOC_FL_KEEP_SIZE) && | 863 | if (!(mode & FALLOC_FL_KEEP_SIZE) && |
| 826 | offset + len > i_size_read(inode)) { | 864 | offset + len > i_size_read(inode)) { |
| 827 | new_size = offset + len; | 865 | new_size = offset + len; |
| @@ -839,28 +877,10 @@ xfs_file_fallocate( | |||
| 839 | goto out_unlock; | 877 | goto out_unlock; |
| 840 | } | 878 | } |
| 841 | 879 | ||
| 842 | tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_WRITEID); | ||
| 843 | error = xfs_trans_reserve(tp, &M_RES(ip->i_mount)->tr_writeid, 0, 0); | ||
| 844 | if (error) { | ||
| 845 | xfs_trans_cancel(tp, 0); | ||
| 846 | goto out_unlock; | ||
| 847 | } | ||
| 848 | |||
| 849 | xfs_ilock(ip, XFS_ILOCK_EXCL); | ||
| 850 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | ||
| 851 | ip->i_d.di_mode &= ~S_ISUID; | ||
| 852 | if (ip->i_d.di_mode & S_IXGRP) | ||
| 853 | ip->i_d.di_mode &= ~S_ISGID; | ||
| 854 | |||
| 855 | if (!(mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE))) | ||
| 856 | ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC; | ||
| 857 | |||
| 858 | xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); | ||
| 859 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | ||
| 860 | |||
| 861 | if (file->f_flags & O_DSYNC) | 880 | if (file->f_flags & O_DSYNC) |
| 862 | xfs_trans_set_sync(tp); | 881 | flags |= XFS_PREALLOC_SYNC; |
| 863 | error = xfs_trans_commit(tp, 0); | 882 | |
| 883 | error = xfs_update_prealloc_flags(ip, flags); | ||
| 864 | if (error) | 884 | if (error) |
| 865 | goto out_unlock; | 885 | goto out_unlock; |
| 866 | 886 | ||
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 41f804e740d7..daafa1f6d260 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
| @@ -1995,6 +1995,7 @@ xfs_iunlink( | |||
| 1995 | agi->agi_unlinked[bucket_index] = cpu_to_be32(agino); | 1995 | agi->agi_unlinked[bucket_index] = cpu_to_be32(agino); |
| 1996 | offset = offsetof(xfs_agi_t, agi_unlinked) + | 1996 | offset = offsetof(xfs_agi_t, agi_unlinked) + |
| 1997 | (sizeof(xfs_agino_t) * bucket_index); | 1997 | (sizeof(xfs_agino_t) * bucket_index); |
| 1998 | xfs_trans_buf_set_type(tp, agibp, XFS_BLFT_AGI_BUF); | ||
| 1998 | xfs_trans_log_buf(tp, agibp, offset, | 1999 | xfs_trans_log_buf(tp, agibp, offset, |
| 1999 | (offset + sizeof(xfs_agino_t) - 1)); | 2000 | (offset + sizeof(xfs_agino_t) - 1)); |
| 2000 | return 0; | 2001 | return 0; |
| @@ -2086,6 +2087,7 @@ xfs_iunlink_remove( | |||
| 2086 | agi->agi_unlinked[bucket_index] = cpu_to_be32(next_agino); | 2087 | agi->agi_unlinked[bucket_index] = cpu_to_be32(next_agino); |
| 2087 | offset = offsetof(xfs_agi_t, agi_unlinked) + | 2088 | offset = offsetof(xfs_agi_t, agi_unlinked) + |
| 2088 | (sizeof(xfs_agino_t) * bucket_index); | 2089 | (sizeof(xfs_agino_t) * bucket_index); |
| 2090 | xfs_trans_buf_set_type(tp, agibp, XFS_BLFT_AGI_BUF); | ||
| 2089 | xfs_trans_log_buf(tp, agibp, offset, | 2091 | xfs_trans_log_buf(tp, agibp, offset, |
| 2090 | (offset + sizeof(xfs_agino_t) - 1)); | 2092 | (offset + sizeof(xfs_agino_t) - 1)); |
| 2091 | } else { | 2093 | } else { |
| @@ -2656,6 +2658,124 @@ xfs_sort_for_rename( | |||
| 2656 | } | 2658 | } |
| 2657 | 2659 | ||
| 2658 | /* | 2660 | /* |
| 2661 | * xfs_cross_rename() | ||
| 2662 | * | ||
| 2663 | * responsible for handling RENAME_EXCHANGE flag in renameat2() sytemcall | ||
| 2664 | */ | ||
| 2665 | STATIC int | ||
| 2666 | xfs_cross_rename( | ||
| 2667 | struct xfs_trans *tp, | ||
| 2668 | struct xfs_inode *dp1, | ||
| 2669 | struct xfs_name *name1, | ||
| 2670 | struct xfs_inode *ip1, | ||
| 2671 | struct xfs_inode *dp2, | ||
| 2672 | struct xfs_name *name2, | ||
| 2673 | struct xfs_inode *ip2, | ||
| 2674 | struct xfs_bmap_free *free_list, | ||
| 2675 | xfs_fsblock_t *first_block, | ||
| 2676 | int spaceres) | ||
| 2677 | { | ||
| 2678 | int error = 0; | ||
| 2679 | int ip1_flags = 0; | ||
| 2680 | int ip2_flags = 0; | ||
| 2681 | int dp2_flags = 0; | ||
| 2682 | |||
| 2683 | /* Swap inode number for dirent in first parent */ | ||
| 2684 | error = xfs_dir_replace(tp, dp1, name1, | ||
| 2685 | ip2->i_ino, | ||
| 2686 | first_block, free_list, spaceres); | ||
| 2687 | if (error) | ||
| 2688 | goto out; | ||
| 2689 | |||
| 2690 | /* Swap inode number for dirent in second parent */ | ||
| 2691 | error = xfs_dir_replace(tp, dp2, name2, | ||
| 2692 | ip1->i_ino, | ||
| 2693 | first_block, free_list, spaceres); | ||
| 2694 | if (error) | ||
| 2695 | goto out; | ||
| 2696 | |||
| 2697 | /* | ||
| 2698 | * If we're renaming one or more directories across different parents, | ||
| 2699 | * update the respective ".." entries (and link counts) to match the new | ||
| 2700 | * parents. | ||
| 2701 | */ | ||
| 2702 | if (dp1 != dp2) { | ||
| 2703 | dp2_flags = XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG; | ||
| 2704 | |||
| 2705 | if (S_ISDIR(ip2->i_d.di_mode)) { | ||
| 2706 | error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot, | ||
| 2707 | dp1->i_ino, first_block, | ||
| 2708 | free_list, spaceres); | ||
| 2709 | if (error) | ||
| 2710 | goto out; | ||
| 2711 | |||
| 2712 | /* transfer ip2 ".." reference to dp1 */ | ||
| 2713 | if (!S_ISDIR(ip1->i_d.di_mode)) { | ||
| 2714 | error = xfs_droplink(tp, dp2); | ||
| 2715 | if (error) | ||
| 2716 | goto out; | ||
| 2717 | error = xfs_bumplink(tp, dp1); | ||
| 2718 | if (error) | ||
| 2719 | goto out; | ||
| 2720 | } | ||
| 2721 | |||
| 2722 | /* | ||
| 2723 | * Although ip1 isn't changed here, userspace needs | ||
| 2724 | * to be warned about the change, so that applications | ||
| 2725 | * relying on it (like backup ones), will properly | ||
| 2726 | * notify the change | ||
| 2727 | */ | ||
| 2728 | ip1_flags |= XFS_ICHGTIME_CHG; | ||
| 2729 | ip2_flags |= XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG; | ||
| 2730 | } | ||
| 2731 | |||
| 2732 | if (S_ISDIR(ip1->i_d.di_mode)) { | ||
| 2733 | error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot, | ||
| 2734 | dp2->i_ino, first_block, | ||
| 2735 | free_list, spaceres); | ||
| 2736 | if (error) | ||
| 2737 | goto out; | ||
| 2738 | |||
| 2739 | /* transfer ip1 ".." reference to dp2 */ | ||
| 2740 | if (!S_ISDIR(ip2->i_d.di_mode)) { | ||
| 2741 | error = xfs_droplink(tp, dp1); | ||
| 2742 | if (error) | ||
| 2743 | goto out; | ||
| 2744 | error = xfs_bumplink(tp, dp2); | ||
| 2745 | if (error) | ||
| 2746 | goto out; | ||
| 2747 | } | ||
| 2748 | |||
| 2749 | /* | ||
| 2750 | * Although ip2 isn't changed here, userspace needs | ||
| 2751 | * to be warned about the change, so that applications | ||
| 2752 | * relying on it (like backup ones), will properly | ||
| 2753 | * notify the change | ||
| 2754 | */ | ||
| 2755 | ip1_flags |= XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG; | ||
| 2756 | ip2_flags |= XFS_ICHGTIME_CHG; | ||
| 2757 | } | ||
| 2758 | } | ||
| 2759 | |||
| 2760 | if (ip1_flags) { | ||
| 2761 | xfs_trans_ichgtime(tp, ip1, ip1_flags); | ||
| 2762 | xfs_trans_log_inode(tp, ip1, XFS_ILOG_CORE); | ||
| 2763 | } | ||
| 2764 | if (ip2_flags) { | ||
| 2765 | xfs_trans_ichgtime(tp, ip2, ip2_flags); | ||
| 2766 | xfs_trans_log_inode(tp, ip2, XFS_ILOG_CORE); | ||
| 2767 | } | ||
| 2768 | if (dp2_flags) { | ||
| 2769 | xfs_trans_ichgtime(tp, dp2, dp2_flags); | ||
| 2770 | xfs_trans_log_inode(tp, dp2, XFS_ILOG_CORE); | ||
| 2771 | } | ||
| 2772 | xfs_trans_ichgtime(tp, dp1, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); | ||
| 2773 | xfs_trans_log_inode(tp, dp1, XFS_ILOG_CORE); | ||
| 2774 | out: | ||
| 2775 | return error; | ||
| 2776 | } | ||
| 2777 | |||
| 2778 | /* | ||
| 2659 | * xfs_rename | 2779 | * xfs_rename |
| 2660 | */ | 2780 | */ |
| 2661 | int | 2781 | int |
| @@ -2665,7 +2785,8 @@ xfs_rename( | |||
| 2665 | xfs_inode_t *src_ip, | 2785 | xfs_inode_t *src_ip, |
| 2666 | xfs_inode_t *target_dp, | 2786 | xfs_inode_t *target_dp, |
| 2667 | struct xfs_name *target_name, | 2787 | struct xfs_name *target_name, |
| 2668 | xfs_inode_t *target_ip) | 2788 | xfs_inode_t *target_ip, |
| 2789 | unsigned int flags) | ||
| 2669 | { | 2790 | { |
| 2670 | xfs_trans_t *tp = NULL; | 2791 | xfs_trans_t *tp = NULL; |
| 2671 | xfs_mount_t *mp = src_dp->i_mount; | 2792 | xfs_mount_t *mp = src_dp->i_mount; |
| @@ -2743,6 +2864,18 @@ xfs_rename( | |||
| 2743 | } | 2864 | } |
| 2744 | 2865 | ||
| 2745 | /* | 2866 | /* |
| 2867 | * Handle RENAME_EXCHANGE flags | ||
| 2868 | */ | ||
| 2869 | if (flags & RENAME_EXCHANGE) { | ||
| 2870 | error = xfs_cross_rename(tp, src_dp, src_name, src_ip, | ||
| 2871 | target_dp, target_name, target_ip, | ||
| 2872 | &free_list, &first_block, spaceres); | ||
| 2873 | if (error) | ||
| 2874 | goto abort_return; | ||
| 2875 | goto finish_rename; | ||
| 2876 | } | ||
| 2877 | |||
| 2878 | /* | ||
| 2746 | * Set up the target. | 2879 | * Set up the target. |
| 2747 | */ | 2880 | */ |
| 2748 | if (target_ip == NULL) { | 2881 | if (target_ip == NULL) { |
| @@ -2881,6 +3014,7 @@ xfs_rename( | |||
| 2881 | if (new_parent) | 3014 | if (new_parent) |
| 2882 | xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); | 3015 | xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); |
| 2883 | 3016 | ||
| 3017 | finish_rename: | ||
| 2884 | /* | 3018 | /* |
| 2885 | * If this is a synchronous mount, make sure that the | 3019 | * If this is a synchronous mount, make sure that the |
| 2886 | * rename transaction goes to disk before returning to | 3020 | * rename transaction goes to disk before returning to |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 4ed2ba9342dc..86cd6b39bed7 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
| @@ -338,7 +338,7 @@ int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip, | |||
| 338 | int xfs_rename(struct xfs_inode *src_dp, struct xfs_name *src_name, | 338 | int xfs_rename(struct xfs_inode *src_dp, struct xfs_name *src_name, |
| 339 | struct xfs_inode *src_ip, struct xfs_inode *target_dp, | 339 | struct xfs_inode *src_ip, struct xfs_inode *target_dp, |
| 340 | struct xfs_name *target_name, | 340 | struct xfs_name *target_name, |
| 341 | struct xfs_inode *target_ip); | 341 | struct xfs_inode *target_ip, unsigned int flags); |
| 342 | 342 | ||
| 343 | void xfs_ilock(xfs_inode_t *, uint); | 343 | void xfs_ilock(xfs_inode_t *, uint); |
| 344 | int xfs_ilock_nowait(xfs_inode_t *, uint); | 344 | int xfs_ilock_nowait(xfs_inode_t *, uint); |
| @@ -377,6 +377,15 @@ int xfs_droplink(struct xfs_trans *, struct xfs_inode *); | |||
| 377 | int xfs_bumplink(struct xfs_trans *, struct xfs_inode *); | 377 | int xfs_bumplink(struct xfs_trans *, struct xfs_inode *); |
| 378 | 378 | ||
| 379 | /* from xfs_file.c */ | 379 | /* from xfs_file.c */ |
| 380 | enum xfs_prealloc_flags { | ||
| 381 | XFS_PREALLOC_SET = (1 << 1), | ||
| 382 | XFS_PREALLOC_CLEAR = (1 << 2), | ||
| 383 | XFS_PREALLOC_SYNC = (1 << 3), | ||
| 384 | XFS_PREALLOC_INVISIBLE = (1 << 4), | ||
| 385 | }; | ||
| 386 | |||
| 387 | int xfs_update_prealloc_flags(struct xfs_inode *, | ||
| 388 | enum xfs_prealloc_flags); | ||
| 380 | int xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t); | 389 | int xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t); |
| 381 | int xfs_iozero(struct xfs_inode *, loff_t, size_t); | 390 | int xfs_iozero(struct xfs_inode *, loff_t, size_t); |
| 382 | 391 | ||
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index f1dc90be508c..f7afb86c9148 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c | |||
| @@ -606,11 +606,8 @@ xfs_ioc_space( | |||
| 606 | unsigned int cmd, | 606 | unsigned int cmd, |
| 607 | xfs_flock64_t *bf) | 607 | xfs_flock64_t *bf) |
| 608 | { | 608 | { |
| 609 | struct xfs_mount *mp = ip->i_mount; | ||
| 610 | struct xfs_trans *tp; | ||
| 611 | struct iattr iattr; | 609 | struct iattr iattr; |
| 612 | bool setprealloc = false; | 610 | enum xfs_prealloc_flags flags = 0; |
| 613 | bool clrprealloc = false; | ||
| 614 | int error; | 611 | int error; |
| 615 | 612 | ||
| 616 | /* | 613 | /* |
| @@ -630,6 +627,11 @@ xfs_ioc_space( | |||
| 630 | if (!S_ISREG(inode->i_mode)) | 627 | if (!S_ISREG(inode->i_mode)) |
| 631 | return -EINVAL; | 628 | return -EINVAL; |
| 632 | 629 | ||
| 630 | if (filp->f_flags & O_DSYNC) | ||
| 631 | flags |= XFS_PREALLOC_SYNC; | ||
| 632 | if (ioflags & XFS_IO_INVIS) | ||
| 633 | flags |= XFS_PREALLOC_INVISIBLE; | ||
| 634 | |||
| 633 | error = mnt_want_write_file(filp); | 635 | error = mnt_want_write_file(filp); |
| 634 | if (error) | 636 | if (error) |
| 635 | return error; | 637 | return error; |
| @@ -673,25 +675,23 @@ xfs_ioc_space( | |||
| 673 | } | 675 | } |
| 674 | 676 | ||
| 675 | if (bf->l_start < 0 || | 677 | if (bf->l_start < 0 || |
| 676 | bf->l_start > mp->m_super->s_maxbytes || | 678 | bf->l_start > inode->i_sb->s_maxbytes || |
| 677 | bf->l_start + bf->l_len < 0 || | 679 | bf->l_start + bf->l_len < 0 || |
| 678 | bf->l_start + bf->l_len >= mp->m_super->s_maxbytes) { | 680 | bf->l_start + bf->l_len >= inode->i_sb->s_maxbytes) { |
| 679 | error = -EINVAL; | 681 | error = -EINVAL; |
| 680 | goto out_unlock; | 682 | goto out_unlock; |
| 681 | } | 683 | } |
| 682 | 684 | ||
| 683 | switch (cmd) { | 685 | switch (cmd) { |
| 684 | case XFS_IOC_ZERO_RANGE: | 686 | case XFS_IOC_ZERO_RANGE: |
| 687 | flags |= XFS_PREALLOC_SET; | ||
| 685 | error = xfs_zero_file_space(ip, bf->l_start, bf->l_len); | 688 | error = xfs_zero_file_space(ip, bf->l_start, bf->l_len); |
| 686 | if (!error) | ||
| 687 | setprealloc = true; | ||
| 688 | break; | 689 | break; |
| 689 | case XFS_IOC_RESVSP: | 690 | case XFS_IOC_RESVSP: |
| 690 | case XFS_IOC_RESVSP64: | 691 | case XFS_IOC_RESVSP64: |
| 692 | flags |= XFS_PREALLOC_SET; | ||
| 691 | error = xfs_alloc_file_space(ip, bf->l_start, bf->l_len, | 693 | error = xfs_alloc_file_space(ip, bf->l_start, bf->l_len, |
| 692 | XFS_BMAPI_PREALLOC); | 694 | XFS_BMAPI_PREALLOC); |
| 693 | if (!error) | ||
| 694 | setprealloc = true; | ||
| 695 | break; | 695 | break; |
| 696 | case XFS_IOC_UNRESVSP: | 696 | case XFS_IOC_UNRESVSP: |
| 697 | case XFS_IOC_UNRESVSP64: | 697 | case XFS_IOC_UNRESVSP64: |
| @@ -701,6 +701,7 @@ xfs_ioc_space( | |||
| 701 | case XFS_IOC_ALLOCSP64: | 701 | case XFS_IOC_ALLOCSP64: |
| 702 | case XFS_IOC_FREESP: | 702 | case XFS_IOC_FREESP: |
| 703 | case XFS_IOC_FREESP64: | 703 | case XFS_IOC_FREESP64: |
| 704 | flags |= XFS_PREALLOC_CLEAR; | ||
| 704 | if (bf->l_start > XFS_ISIZE(ip)) { | 705 | if (bf->l_start > XFS_ISIZE(ip)) { |
| 705 | error = xfs_alloc_file_space(ip, XFS_ISIZE(ip), | 706 | error = xfs_alloc_file_space(ip, XFS_ISIZE(ip), |
| 706 | bf->l_start - XFS_ISIZE(ip), 0); | 707 | bf->l_start - XFS_ISIZE(ip), 0); |
| @@ -712,8 +713,6 @@ xfs_ioc_space( | |||
| 712 | iattr.ia_size = bf->l_start; | 713 | iattr.ia_size = bf->l_start; |
| 713 | 714 | ||
| 714 | error = xfs_setattr_size(ip, &iattr); | 715 | error = xfs_setattr_size(ip, &iattr); |
| 715 | if (!error) | ||
| 716 | clrprealloc = true; | ||
| 717 | break; | 716 | break; |
| 718 | default: | 717 | default: |
| 719 | ASSERT(0); | 718 | ASSERT(0); |
| @@ -723,32 +722,7 @@ xfs_ioc_space( | |||
| 723 | if (error) | 722 | if (error) |
| 724 | goto out_unlock; | 723 | goto out_unlock; |
| 725 | 724 | ||
| 726 | tp = xfs_trans_alloc(mp, XFS_TRANS_WRITEID); | 725 | error = xfs_update_prealloc_flags(ip, flags); |
| 727 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_writeid, 0, 0); | ||
| 728 | if (error) { | ||
| 729 | xfs_trans_cancel(tp, 0); | ||
| 730 | goto out_unlock; | ||
| 731 | } | ||
| 732 | |||
| 733 | xfs_ilock(ip, XFS_ILOCK_EXCL); | ||
| 734 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | ||
| 735 | |||
| 736 | if (!(ioflags & XFS_IO_INVIS)) { | ||
| 737 | ip->i_d.di_mode &= ~S_ISUID; | ||
| 738 | if (ip->i_d.di_mode & S_IXGRP) | ||
| 739 | ip->i_d.di_mode &= ~S_ISGID; | ||
| 740 | xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); | ||
| 741 | } | ||
| 742 | |||
| 743 | if (setprealloc) | ||
| 744 | ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC; | ||
| 745 | else if (clrprealloc) | ||
| 746 | ip->i_d.di_flags &= ~XFS_DIFLAG_PREALLOC; | ||
| 747 | |||
| 748 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | ||
| 749 | if (filp->f_flags & O_DSYNC) | ||
| 750 | xfs_trans_set_sync(tp); | ||
| 751 | error = xfs_trans_commit(tp, 0); | ||
| 752 | 726 | ||
| 753 | out_unlock: | 727 | out_unlock: |
| 754 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | 728 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); |
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index ec6772866f3d..bfc7c7c8a0c8 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c | |||
| @@ -423,7 +423,7 @@ xfs_compat_attrmulti_by_handle( | |||
| 423 | 423 | ||
| 424 | ops = memdup_user(compat_ptr(am_hreq.ops), size); | 424 | ops = memdup_user(compat_ptr(am_hreq.ops), size); |
| 425 | if (IS_ERR(ops)) { | 425 | if (IS_ERR(ops)) { |
| 426 | error = -PTR_ERR(ops); | 426 | error = PTR_ERR(ops); |
| 427 | goto out_dput; | 427 | goto out_dput; |
| 428 | } | 428 | } |
| 429 | 429 | ||
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index c980e2a5086b..ccb1dd0d509e 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
| @@ -802,7 +802,7 @@ int | |||
| 802 | xfs_iomap_write_unwritten( | 802 | xfs_iomap_write_unwritten( |
| 803 | xfs_inode_t *ip, | 803 | xfs_inode_t *ip, |
| 804 | xfs_off_t offset, | 804 | xfs_off_t offset, |
| 805 | size_t count) | 805 | xfs_off_t count) |
| 806 | { | 806 | { |
| 807 | xfs_mount_t *mp = ip->i_mount; | 807 | xfs_mount_t *mp = ip->i_mount; |
| 808 | xfs_fileoff_t offset_fsb; | 808 | xfs_fileoff_t offset_fsb; |
diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h index 411fbb8919ef..8688e663d744 100644 --- a/fs/xfs/xfs_iomap.h +++ b/fs/xfs/xfs_iomap.h | |||
| @@ -27,6 +27,6 @@ int xfs_iomap_write_delay(struct xfs_inode *, xfs_off_t, size_t, | |||
| 27 | struct xfs_bmbt_irec *); | 27 | struct xfs_bmbt_irec *); |
| 28 | int xfs_iomap_write_allocate(struct xfs_inode *, xfs_off_t, | 28 | int xfs_iomap_write_allocate(struct xfs_inode *, xfs_off_t, |
| 29 | struct xfs_bmbt_irec *); | 29 | struct xfs_bmbt_irec *); |
| 30 | int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, size_t); | 30 | int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t); |
| 31 | 31 | ||
| 32 | #endif /* __XFS_IOMAP_H__*/ | 32 | #endif /* __XFS_IOMAP_H__*/ |
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index c50311cae1b1..ce80eeb8faa4 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
| @@ -380,18 +380,27 @@ xfs_vn_rename( | |||
| 380 | struct inode *odir, | 380 | struct inode *odir, |
| 381 | struct dentry *odentry, | 381 | struct dentry *odentry, |
| 382 | struct inode *ndir, | 382 | struct inode *ndir, |
| 383 | struct dentry *ndentry) | 383 | struct dentry *ndentry, |
| 384 | unsigned int flags) | ||
| 384 | { | 385 | { |
| 385 | struct inode *new_inode = ndentry->d_inode; | 386 | struct inode *new_inode = ndentry->d_inode; |
| 387 | int omode = 0; | ||
| 386 | struct xfs_name oname; | 388 | struct xfs_name oname; |
| 387 | struct xfs_name nname; | 389 | struct xfs_name nname; |
| 388 | 390 | ||
| 389 | xfs_dentry_to_name(&oname, odentry, 0); | 391 | if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) |
| 392 | return -EINVAL; | ||
| 393 | |||
| 394 | /* if we are exchanging files, we need to set i_mode of both files */ | ||
| 395 | if (flags & RENAME_EXCHANGE) | ||
| 396 | omode = ndentry->d_inode->i_mode; | ||
| 397 | |||
| 398 | xfs_dentry_to_name(&oname, odentry, omode); | ||
| 390 | xfs_dentry_to_name(&nname, ndentry, odentry->d_inode->i_mode); | 399 | xfs_dentry_to_name(&nname, ndentry, odentry->d_inode->i_mode); |
| 391 | 400 | ||
| 392 | return xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode), | 401 | return xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode), |
| 393 | XFS_I(ndir), &nname, new_inode ? | 402 | XFS_I(ndir), &nname, |
| 394 | XFS_I(new_inode) : NULL); | 403 | new_inode ? XFS_I(new_inode) : NULL, flags); |
| 395 | } | 404 | } |
| 396 | 405 | ||
| 397 | /* | 406 | /* |
| @@ -1144,7 +1153,7 @@ static const struct inode_operations xfs_dir_inode_operations = { | |||
| 1144 | */ | 1153 | */ |
| 1145 | .rmdir = xfs_vn_unlink, | 1154 | .rmdir = xfs_vn_unlink, |
| 1146 | .mknod = xfs_vn_mknod, | 1155 | .mknod = xfs_vn_mknod, |
| 1147 | .rename = xfs_vn_rename, | 1156 | .rename2 = xfs_vn_rename, |
| 1148 | .get_acl = xfs_get_acl, | 1157 | .get_acl = xfs_get_acl, |
| 1149 | .set_acl = xfs_set_acl, | 1158 | .set_acl = xfs_set_acl, |
| 1150 | .getattr = xfs_vn_getattr, | 1159 | .getattr = xfs_vn_getattr, |
| @@ -1172,7 +1181,7 @@ static const struct inode_operations xfs_dir_ci_inode_operations = { | |||
| 1172 | */ | 1181 | */ |
| 1173 | .rmdir = xfs_vn_unlink, | 1182 | .rmdir = xfs_vn_unlink, |
| 1174 | .mknod = xfs_vn_mknod, | 1183 | .mknod = xfs_vn_mknod, |
| 1175 | .rename = xfs_vn_rename, | 1184 | .rename2 = xfs_vn_rename, |
| 1176 | .get_acl = xfs_get_acl, | 1185 | .get_acl = xfs_get_acl, |
| 1177 | .set_acl = xfs_set_acl, | 1186 | .set_acl = xfs_set_acl, |
| 1178 | .getattr = xfs_vn_getattr, | 1187 | .getattr = xfs_vn_getattr, |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 2b8dcf2b3dd1..bcc7cfabb787 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
| @@ -1407,6 +1407,8 @@ xlog_alloc_log( | |||
| 1407 | ASSERT(xfs_buf_islocked(bp)); | 1407 | ASSERT(xfs_buf_islocked(bp)); |
| 1408 | xfs_buf_unlock(bp); | 1408 | xfs_buf_unlock(bp); |
| 1409 | 1409 | ||
| 1410 | /* use high priority wq for log I/O completion */ | ||
| 1411 | bp->b_ioend_wq = mp->m_log_workqueue; | ||
| 1410 | bp->b_iodone = xlog_iodone; | 1412 | bp->b_iodone = xlog_iodone; |
| 1411 | log->l_xbuf = bp; | 1413 | log->l_xbuf = bp; |
| 1412 | 1414 | ||
| @@ -1439,6 +1441,8 @@ xlog_alloc_log( | |||
| 1439 | ASSERT(xfs_buf_islocked(bp)); | 1441 | ASSERT(xfs_buf_islocked(bp)); |
| 1440 | xfs_buf_unlock(bp); | 1442 | xfs_buf_unlock(bp); |
| 1441 | 1443 | ||
| 1444 | /* use high priority wq for log I/O completion */ | ||
| 1445 | bp->b_ioend_wq = mp->m_log_workqueue; | ||
| 1442 | bp->b_iodone = xlog_iodone; | 1446 | bp->b_iodone = xlog_iodone; |
| 1443 | iclog->ic_bp = bp; | 1447 | iclog->ic_bp = bp; |
| 1444 | iclog->ic_data = bp->b_addr; | 1448 | iclog->ic_data = bp->b_addr; |
| @@ -1818,8 +1822,6 @@ xlog_sync( | |||
| 1818 | XFS_BUF_ZEROFLAGS(bp); | 1822 | XFS_BUF_ZEROFLAGS(bp); |
| 1819 | XFS_BUF_ASYNC(bp); | 1823 | XFS_BUF_ASYNC(bp); |
| 1820 | bp->b_flags |= XBF_SYNCIO; | 1824 | bp->b_flags |= XBF_SYNCIO; |
| 1821 | /* use high priority completion wq */ | ||
| 1822 | bp->b_ioend_wq = log->l_mp->m_log_workqueue; | ||
| 1823 | 1825 | ||
| 1824 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) { | 1826 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) { |
| 1825 | bp->b_flags |= XBF_FUA; | 1827 | bp->b_flags |= XBF_FUA; |
| @@ -1868,8 +1870,6 @@ xlog_sync( | |||
| 1868 | bp->b_flags |= XBF_SYNCIO; | 1870 | bp->b_flags |= XBF_SYNCIO; |
| 1869 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) | 1871 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) |
| 1870 | bp->b_flags |= XBF_FUA; | 1872 | bp->b_flags |= XBF_FUA; |
| 1871 | /* use high priority completion wq */ | ||
| 1872 | bp->b_ioend_wq = log->l_mp->m_log_workqueue; | ||
| 1873 | 1873 | ||
| 1874 | ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); | 1874 | ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); |
| 1875 | ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize); | 1875 | ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize); |
| @@ -2039,7 +2039,7 @@ xlog_print_tic_res( | |||
| 2039 | " total reg = %u bytes (o/flow = %u bytes)\n" | 2039 | " total reg = %u bytes (o/flow = %u bytes)\n" |
| 2040 | " ophdrs = %u (ophdr space = %u bytes)\n" | 2040 | " ophdrs = %u (ophdr space = %u bytes)\n" |
| 2041 | " ophdr + reg = %u bytes\n" | 2041 | " ophdr + reg = %u bytes\n" |
| 2042 | " num regions = %u\n", | 2042 | " num regions = %u", |
| 2043 | ((ticket->t_trans_type <= 0 || | 2043 | ((ticket->t_trans_type <= 0 || |
| 2044 | ticket->t_trans_type > XFS_TRANS_TYPE_MAX) ? | 2044 | ticket->t_trans_type > XFS_TRANS_TYPE_MAX) ? |
| 2045 | "bad-trans-type" : trans_type_str[ticket->t_trans_type-1]), | 2045 | "bad-trans-type" : trans_type_str[ticket->t_trans_type-1]), |
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 26afa436fafe..f2449fd86926 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
| @@ -685,7 +685,7 @@ xfs_blkdev_get( | |||
| 685 | mp); | 685 | mp); |
| 686 | if (IS_ERR(*bdevp)) { | 686 | if (IS_ERR(*bdevp)) { |
| 687 | error = PTR_ERR(*bdevp); | 687 | error = PTR_ERR(*bdevp); |
| 688 | xfs_warn(mp, "Invalid device [%s], error=%d\n", name, error); | 688 | xfs_warn(mp, "Invalid device [%s], error=%d", name, error); |
| 689 | } | 689 | } |
| 690 | 690 | ||
| 691 | return error; | 691 | return error; |
diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c index 1743b9f8e23d..a0c8067cea6f 100644 --- a/fs/xfs/xfs_sysctl.c +++ b/fs/xfs/xfs_sysctl.c | |||
| @@ -149,24 +149,6 @@ static struct ctl_table xfs_table[] = { | |||
| 149 | .extra2 = &xfs_params.inherit_noatim.max | 149 | .extra2 = &xfs_params.inherit_noatim.max |
| 150 | }, | 150 | }, |
| 151 | { | 151 | { |
| 152 | .procname = "xfsbufd_centisecs", | ||
| 153 | .data = &xfs_params.xfs_buf_timer.val, | ||
| 154 | .maxlen = sizeof(int), | ||
| 155 | .mode = 0644, | ||
| 156 | .proc_handler = proc_dointvec_minmax, | ||
| 157 | .extra1 = &xfs_params.xfs_buf_timer.min, | ||
| 158 | .extra2 = &xfs_params.xfs_buf_timer.max | ||
| 159 | }, | ||
| 160 | { | ||
| 161 | .procname = "age_buffer_centisecs", | ||
| 162 | .data = &xfs_params.xfs_buf_age.val, | ||
| 163 | .maxlen = sizeof(int), | ||
| 164 | .mode = 0644, | ||
| 165 | .proc_handler = proc_dointvec_minmax, | ||
| 166 | .extra1 = &xfs_params.xfs_buf_age.min, | ||
| 167 | .extra2 = &xfs_params.xfs_buf_age.max | ||
| 168 | }, | ||
| 169 | { | ||
| 170 | .procname = "inherit_nosymlinks", | 152 | .procname = "inherit_nosymlinks", |
| 171 | .data = &xfs_params.inherit_nosym.val, | 153 | .data = &xfs_params.inherit_nosym.val, |
| 172 | .maxlen = sizeof(int), | 154 | .maxlen = sizeof(int), |
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index fa3135b9bf04..eb90cd59a0ec 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c | |||
| @@ -472,6 +472,7 @@ xfs_trans_apply_sb_deltas( | |||
| 472 | whole = 1; | 472 | whole = 1; |
| 473 | } | 473 | } |
| 474 | 474 | ||
| 475 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); | ||
| 475 | if (whole) | 476 | if (whole) |
| 476 | /* | 477 | /* |
| 477 | * Log the whole thing, the fields are noncontiguous. | 478 | * Log the whole thing, the fields are noncontiguous. |
