aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2016-02-09 00:54:58 -0500
committerDave Chinner <david@fromorbit.com>2016-02-09 00:54:58 -0500
commitfaeb4e4715be017e88e630bda84477afc1dff38b (patch)
treece03ca459a3bbefd7be3ee31b295e3948935c20c
parent93f958f9c41f0bfd10627a2279457df64004d957 (diff)
xfs: move v1 inode conversion to xfs_inode_from_disk
So we don't have to carry an di_onlink variable around anymore, move the inode conversion from v1 inode format to v2 inode format into xfs_inode_from_disk(). This means we can remove the di_onlink fields from the struct xfs_icdinode. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c42
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.h1
-rw-r--r--fs/xfs/libxfs/xfs_log_format.h2
-rw-r--r--fs/xfs/xfs_inode.c2
-rw-r--r--fs/xfs/xfs_inode_item.c2
5 files changed, 22 insertions, 27 deletions
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index c0fe062b567a..fe8f4f349b37 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -204,13 +204,25 @@ xfs_inode_from_disk(
204 204
205 to->di_mode = be16_to_cpu(from->di_mode); 205 to->di_mode = be16_to_cpu(from->di_mode);
206 to->di_version = from ->di_version; 206 to->di_version = from ->di_version;
207
208 /*
209 * Convert v1 inodes immediately to v2 inode format as this is the
210 * minimum inode version format we support in the rest of the code.
211 */
212 if (to->di_version == 1) {
213 to->di_nlink = be16_to_cpu(from->di_onlink);
214 to->di_projid_lo = 0;
215 to->di_projid_hi = 0;
216 to->di_version = 2;
217 } else {
218 to->di_nlink = be32_to_cpu(from->di_nlink);
219 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
220 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
221 }
222
207 to->di_format = from->di_format; 223 to->di_format = from->di_format;
208 to->di_onlink = be16_to_cpu(from->di_onlink);
209 to->di_uid = be32_to_cpu(from->di_uid); 224 to->di_uid = be32_to_cpu(from->di_uid);
210 to->di_gid = be32_to_cpu(from->di_gid); 225 to->di_gid = be32_to_cpu(from->di_gid);
211 to->di_nlink = be32_to_cpu(from->di_nlink);
212 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
213 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
214 to->di_flushiter = be16_to_cpu(from->di_flushiter); 226 to->di_flushiter = be16_to_cpu(from->di_flushiter);
215 227
216 /* 228 /*
@@ -256,11 +268,11 @@ xfs_inode_to_disk(
256 struct inode *inode = VFS_I(ip); 268 struct inode *inode = VFS_I(ip);
257 269
258 to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC); 270 to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
271 to->di_onlink = 0;
259 272
260 to->di_mode = cpu_to_be16(from->di_mode); 273 to->di_mode = cpu_to_be16(from->di_mode);
261 to->di_version = from->di_version; 274 to->di_version = from->di_version;
262 to->di_format = from->di_format; 275 to->di_format = from->di_format;
263 to->di_onlink = cpu_to_be16(from->di_onlink);
264 to->di_uid = cpu_to_be32(from->di_uid); 276 to->di_uid = cpu_to_be32(from->di_uid);
265 to->di_gid = cpu_to_be32(from->di_gid); 277 to->di_gid = cpu_to_be32(from->di_gid);
266 to->di_nlink = cpu_to_be32(from->di_nlink); 278 to->di_nlink = cpu_to_be32(from->di_nlink);
@@ -310,9 +322,9 @@ xfs_log_dinode_to_disk(
310{ 322{
311 to->di_magic = cpu_to_be16(from->di_magic); 323 to->di_magic = cpu_to_be16(from->di_magic);
312 to->di_mode = cpu_to_be16(from->di_mode); 324 to->di_mode = cpu_to_be16(from->di_mode);
313 to->di_version = from ->di_version; 325 to->di_version = from->di_version;
314 to->di_format = from->di_format; 326 to->di_format = from->di_format;
315 to->di_onlink = cpu_to_be16(from->di_onlink); 327 to->di_onlink = 0;
316 to->di_uid = cpu_to_be32(from->di_uid); 328 to->di_uid = cpu_to_be32(from->di_uid);
317 to->di_gid = cpu_to_be32(from->di_gid); 329 to->di_gid = cpu_to_be32(from->di_gid);
318 to->di_nlink = cpu_to_be32(from->di_nlink); 330 to->di_nlink = cpu_to_be32(from->di_nlink);
@@ -492,21 +504,7 @@ xfs_iread(
492 ip->i_d.di_mode = 0; 504 ip->i_d.di_mode = 0;
493 } 505 }
494 506
495 /* 507 ASSERT(ip->i_d.di_version >= 2);
496 * Automatically convert version 1 inode formats in memory to version 2
497 * inode format. If the inode is modified, it will get logged and
498 * rewritten as a version 2 inode. We can do this because we set the
499 * superblock feature bit for v2 inodes unconditionally during mount
500 * and it means the reast of the code can assume the inode version is 2
501 * or higher.
502 */
503 if (ip->i_d.di_version == 1) {
504 ip->i_d.di_version = 2;
505 ip->i_d.di_nlink = ip->i_d.di_onlink;
506 ip->i_d.di_onlink = 0;
507 xfs_set_projid(ip, 0);
508 }
509
510 ip->i_delayed_blks = 0; 508 ip->i_delayed_blks = 0;
511 509
512 /* 510 /*
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 7b8b1b97918b..73ba1d8ffac2 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -31,7 +31,6 @@ struct xfs_icdinode {
31 __uint16_t di_mode; /* mode and type of file */ 31 __uint16_t di_mode; /* mode and type of file */
32 __int8_t di_version; /* inode version */ 32 __int8_t di_version; /* inode version */
33 __int8_t di_format; /* format of di_c data */ 33 __int8_t di_format; /* format of di_c data */
34 __uint16_t di_onlink; /* old number of links to file */
35 __uint16_t di_flushiter; /* incremented on flush */ 34 __uint16_t di_flushiter; /* incremented on flush */
36 __uint32_t di_uid; /* owner's user id */ 35 __uint32_t di_uid; /* owner's user id */
37 __uint32_t di_gid; /* owner's group id */ 36 __uint32_t di_gid; /* owner's group id */
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index d00ed639e0bc..03f90b99b8c8 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -369,7 +369,7 @@ struct xfs_log_dinode {
369 __uint16_t di_mode; /* mode and type of file */ 369 __uint16_t di_mode; /* mode and type of file */
370 __int8_t di_version; /* inode version */ 370 __int8_t di_version; /* inode version */
371 __int8_t di_format; /* format of di_c data */ 371 __int8_t di_format; /* format of di_c data */
372 __uint16_t di_onlink; /* old number of links to file */ 372 __uint8_t di_pad3[2]; /* unused in v2/3 inodes */
373 __uint32_t di_uid; /* owner's user id */ 373 __uint32_t di_uid; /* owner's user id */
374 __uint32_t di_gid; /* owner's group id */ 374 __uint32_t di_gid; /* owner's group id */
375 __uint32_t di_nlink; /* number of links to file */ 375 __uint32_t di_nlink; /* number of links to file */
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 45acdee98983..7d9c514fd231 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -803,9 +803,7 @@ xfs_ialloc(
803 ip->i_d.di_version = 2; 803 ip->i_d.di_version = 2;
804 804
805 ip->i_d.di_mode = mode; 805 ip->i_d.di_mode = mode;
806 ip->i_d.di_onlink = 0;
807 ip->i_d.di_nlink = nlink; 806 ip->i_d.di_nlink = nlink;
808 ASSERT(ip->i_d.di_nlink == nlink);
809 ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid()); 807 ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid());
810 ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid()); 808 ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid());
811 xfs_set_projid(ip, prid); 809 xfs_set_projid(ip, prid);
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 588d1b4523cb..1e5ecbc45459 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -336,7 +336,6 @@ xfs_inode_to_log_dinode(
336 to->di_mode = from->di_mode; 336 to->di_mode = from->di_mode;
337 to->di_version = from->di_version; 337 to->di_version = from->di_version;
338 to->di_format = from->di_format; 338 to->di_format = from->di_format;
339 to->di_onlink = from->di_onlink;
340 to->di_uid = from->di_uid; 339 to->di_uid = from->di_uid;
341 to->di_gid = from->di_gid; 340 to->di_gid = from->di_gid;
342 to->di_nlink = from->di_nlink; 341 to->di_nlink = from->di_nlink;
@@ -344,6 +343,7 @@ xfs_inode_to_log_dinode(
344 to->di_projid_hi = from->di_projid_hi; 343 to->di_projid_hi = from->di_projid_hi;
345 344
346 memset(to->di_pad, 0, sizeof(to->di_pad)); 345 memset(to->di_pad, 0, sizeof(to->di_pad));
346 memset(to->di_pad3, 0, sizeof(to->di_pad3));
347 to->di_atime.t_sec = inode->i_atime.tv_sec; 347 to->di_atime.t_sec = inode->i_atime.tv_sec;
348 to->di_atime.t_nsec = inode->i_atime.tv_nsec; 348 to->di_atime.t_nsec = inode->i_atime.tv_nsec;
349 to->di_mtime.t_sec = inode->i_mtime.tv_sec; 349 to->di_mtime.t_sec = inode->i_mtime.tv_sec;