diff options
Diffstat (limited to 'fs/xfs/xfs_inode.c')
| -rw-r--r-- | fs/xfs/xfs_inode.c | 39 | 
1 files changed, 27 insertions, 12 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 3ca5d43b8345..cdc4c28926d0 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c  | |||
| @@ -48,7 +48,9 @@ | |||
| 48 | #include "xfs_dir2_trace.h" | 48 | #include "xfs_dir2_trace.h" | 
| 49 | #include "xfs_quota.h" | 49 | #include "xfs_quota.h" | 
| 50 | #include "xfs_acl.h" | 50 | #include "xfs_acl.h" | 
| 51 | #include "xfs_filestream.h" | ||
| 51 | 52 | ||
| 53 | #include <linux/log2.h> | ||
| 52 | 54 | ||
| 53 | kmem_zone_t *xfs_ifork_zone; | 55 | kmem_zone_t *xfs_ifork_zone; | 
| 54 | kmem_zone_t *xfs_inode_zone; | 56 | kmem_zone_t *xfs_inode_zone; | 
| @@ -643,8 +645,7 @@ xfs_iformat_extents( | |||
| 643 | ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), | 645 | ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), | 
| 644 | ARCH_CONVERT); | 646 | ARCH_CONVERT); | 
| 645 | } | 647 | } | 
| 646 | xfs_bmap_trace_exlist("xfs_iformat_extents", ip, nex, | 648 | XFS_BMAP_TRACE_EXLIST(ip, nex, whichfork); | 
| 647 | whichfork); | ||
| 648 | if (whichfork != XFS_DATA_FORK || | 649 | if (whichfork != XFS_DATA_FORK || | 
| 649 | XFS_EXTFMT_INODE(ip) == XFS_EXTFMT_NOSTATE) | 650 | XFS_EXTFMT_INODE(ip) == XFS_EXTFMT_NOSTATE) | 
| 650 | if (unlikely(xfs_check_nostate_extents( | 651 | if (unlikely(xfs_check_nostate_extents( | 
| @@ -817,6 +818,8 @@ _xfs_dic2xflags( | |||
| 817 | flags |= XFS_XFLAG_EXTSZINHERIT; | 818 | flags |= XFS_XFLAG_EXTSZINHERIT; | 
| 818 | if (di_flags & XFS_DIFLAG_NODEFRAG) | 819 | if (di_flags & XFS_DIFLAG_NODEFRAG) | 
| 819 | flags |= XFS_XFLAG_NODEFRAG; | 820 | flags |= XFS_XFLAG_NODEFRAG; | 
| 821 | if (di_flags & XFS_DIFLAG_FILESTREAM) | ||
| 822 | flags |= XFS_XFLAG_FILESTREAM; | ||
| 820 | } | 823 | } | 
| 821 | 824 | ||
| 822 | return flags; | 825 | return flags; | 
| @@ -1074,6 +1077,11 @@ xfs_iread_extents( | |||
| 1074 | * also returns the [locked] bp pointing to the head of the freelist | 1077 | * also returns the [locked] bp pointing to the head of the freelist | 
| 1075 | * as ialloc_context. The caller should hold this buffer across | 1078 | * as ialloc_context. The caller should hold this buffer across | 
| 1076 | * the commit and pass it back into this routine on the second call. | 1079 | * the commit and pass it back into this routine on the second call. | 
| 1080 | * | ||
| 1081 | * If we are allocating quota inodes, we do not have a parent inode | ||
| 1082 | * to attach to or associate with (i.e. pip == NULL) because they | ||
| 1083 | * are not linked into the directory structure - they are attached | ||
| 1084 | * directly to the superblock - and so have no parent. | ||
| 1077 | */ | 1085 | */ | 
| 1078 | int | 1086 | int | 
| 1079 | xfs_ialloc( | 1087 | xfs_ialloc( | 
| @@ -1099,7 +1107,7 @@ xfs_ialloc( | |||
| 1099 | * Call the space management code to pick | 1107 | * Call the space management code to pick | 
| 1100 | * the on-disk inode to be allocated. | 1108 | * the on-disk inode to be allocated. | 
| 1101 | */ | 1109 | */ | 
| 1102 | error = xfs_dialloc(tp, pip->i_ino, mode, okalloc, | 1110 | error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode, okalloc, | 
| 1103 | ialloc_context, call_again, &ino); | 1111 | ialloc_context, call_again, &ino); | 
| 1104 | if (error != 0) { | 1112 | if (error != 0) { | 
| 1105 | return error; | 1113 | return error; | 
| @@ -1150,10 +1158,10 @@ xfs_ialloc( | |||
| 1150 | /* | 1158 | /* | 
| 1151 | * Project ids won't be stored on disk if we are using a version 1 inode. | 1159 | * Project ids won't be stored on disk if we are using a version 1 inode. | 
| 1152 | */ | 1160 | */ | 
| 1153 | if ( (prid != 0) && (ip->i_d.di_version == XFS_DINODE_VERSION_1)) | 1161 | if ((prid != 0) && (ip->i_d.di_version == XFS_DINODE_VERSION_1)) | 
| 1154 | xfs_bump_ino_vers2(tp, ip); | 1162 | xfs_bump_ino_vers2(tp, ip); | 
| 1155 | 1163 | ||
| 1156 | if (XFS_INHERIT_GID(pip, vp->v_vfsp)) { | 1164 | if (pip && XFS_INHERIT_GID(pip, vp->v_vfsp)) { | 
| 1157 | ip->i_d.di_gid = pip->i_d.di_gid; | 1165 | ip->i_d.di_gid = pip->i_d.di_gid; | 
| 1158 | if ((pip->i_d.di_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR) { | 1166 | if ((pip->i_d.di_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR) { | 
| 1159 | ip->i_d.di_mode |= S_ISGID; | 1167 | ip->i_d.di_mode |= S_ISGID; | 
| @@ -1195,8 +1203,16 @@ xfs_ialloc( | |||
| 1195 | flags |= XFS_ILOG_DEV; | 1203 | flags |= XFS_ILOG_DEV; | 
| 1196 | break; | 1204 | break; | 
| 1197 | case S_IFREG: | 1205 | case S_IFREG: | 
| 1206 | if (pip && xfs_inode_is_filestream(pip)) { | ||
| 1207 | error = xfs_filestream_associate(pip, ip); | ||
| 1208 | if (error < 0) | ||
| 1209 | return -error; | ||
| 1210 | if (!error) | ||
| 1211 | xfs_iflags_set(ip, XFS_IFILESTREAM); | ||
| 1212 | } | ||
| 1213 | /* fall through */ | ||
| 1198 | case S_IFDIR: | 1214 | case S_IFDIR: | 
| 1199 | if (unlikely(pip->i_d.di_flags & XFS_DIFLAG_ANY)) { | 1215 | if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) { | 
| 1200 | uint di_flags = 0; | 1216 | uint di_flags = 0; | 
| 1201 | 1217 | ||
| 1202 | if ((mode & S_IFMT) == S_IFDIR) { | 1218 | if ((mode & S_IFMT) == S_IFDIR) { | 
| @@ -1233,6 +1249,8 @@ xfs_ialloc( | |||
| 1233 | if ((pip->i_d.di_flags & XFS_DIFLAG_NODEFRAG) && | 1249 | if ((pip->i_d.di_flags & XFS_DIFLAG_NODEFRAG) && | 
| 1234 | xfs_inherit_nodefrag) | 1250 | xfs_inherit_nodefrag) | 
| 1235 | di_flags |= XFS_DIFLAG_NODEFRAG; | 1251 | di_flags |= XFS_DIFLAG_NODEFRAG; | 
| 1252 | if (pip->i_d.di_flags & XFS_DIFLAG_FILESTREAM) | ||
| 1253 | di_flags |= XFS_DIFLAG_FILESTREAM; | ||
| 1236 | ip->i_d.di_flags |= di_flags; | 1254 | ip->i_d.di_flags |= di_flags; | 
| 1237 | } | 1255 | } | 
| 1238 | /* FALLTHROUGH */ | 1256 | /* FALLTHROUGH */ | 
| @@ -2875,9 +2893,6 @@ xfs_iextents_copy( | |||
| 2875 | int copied; | 2893 | int copied; | 
| 2876 | xfs_bmbt_rec_t *dest_ep; | 2894 | xfs_bmbt_rec_t *dest_ep; | 
| 2877 | xfs_bmbt_rec_t *ep; | 2895 | xfs_bmbt_rec_t *ep; | 
| 2878 | #ifdef XFS_BMAP_TRACE | ||
| 2879 | static char fname[] = "xfs_iextents_copy"; | ||
| 2880 | #endif | ||
| 2881 | int i; | 2896 | int i; | 
| 2882 | xfs_ifork_t *ifp; | 2897 | xfs_ifork_t *ifp; | 
| 2883 | int nrecs; | 2898 | int nrecs; | 
| @@ -2888,7 +2903,7 @@ xfs_iextents_copy( | |||
| 2888 | ASSERT(ifp->if_bytes > 0); | 2903 | ASSERT(ifp->if_bytes > 0); | 
| 2889 | 2904 | ||
| 2890 | nrecs = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 2905 | nrecs = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 
| 2891 | xfs_bmap_trace_exlist(fname, ip, nrecs, whichfork); | 2906 | XFS_BMAP_TRACE_EXLIST(ip, nrecs, whichfork); | 
| 2892 | ASSERT(nrecs > 0); | 2907 | ASSERT(nrecs > 0); | 
| 2893 | 2908 | ||
| 2894 | /* | 2909 | /* | 
| @@ -4184,7 +4199,7 @@ xfs_iext_realloc_direct( | |||
| 4184 | ifp->if_bytes = new_size; | 4199 | ifp->if_bytes = new_size; | 
| 4185 | return; | 4200 | return; | 
| 4186 | } | 4201 | } | 
| 4187 | if ((new_size & (new_size - 1)) != 0) { | 4202 | if (!is_power_of_2(new_size)){ | 
| 4188 | rnew_size = xfs_iroundup(new_size); | 4203 | rnew_size = xfs_iroundup(new_size); | 
| 4189 | } | 4204 | } | 
| 4190 | if (rnew_size != ifp->if_real_bytes) { | 4205 | if (rnew_size != ifp->if_real_bytes) { | 
| @@ -4207,7 +4222,7 @@ xfs_iext_realloc_direct( | |||
| 4207 | */ | 4222 | */ | 
| 4208 | else { | 4223 | else { | 
| 4209 | new_size += ifp->if_bytes; | 4224 | new_size += ifp->if_bytes; | 
| 4210 | if ((new_size & (new_size - 1)) != 0) { | 4225 | if (!is_power_of_2(new_size)) { | 
| 4211 | rnew_size = xfs_iroundup(new_size); | 4226 | rnew_size = xfs_iroundup(new_size); | 
| 4212 | } | 4227 | } | 
| 4213 | xfs_iext_inline_to_direct(ifp, rnew_size); | 4228 | xfs_iext_inline_to_direct(ifp, rnew_size); | 
