diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-10-31 21:45:08 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-11-30 10:34:11 -0500 |
commit | e7f14f4d094ea1a9ce1953375f5bc1500c760c79 (patch) | |
tree | da539b26dedd351ecb591e7ccb571b94a679452e /fs | |
parent | af339c0241d0dd3b35f9097b4f4999bb22ffe502 (diff) |
[GFS2] Shrink gfs2_inode (2) - di_major/di_minor
This removes the device numbers from this structure by using
inode->i_rdev instead. It also cleans up the code in gfs2_mknod.
It results in shrinking the gfs2_inode by 8 bytes.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/inode.c | 36 | ||||
-rw-r--r-- | fs/gfs2/inode.h | 2 | ||||
-rw-r--r-- | fs/gfs2/ondisk.c | 4 | ||||
-rw-r--r-- | fs/gfs2/ops_inode.c | 38 |
4 files changed, 22 insertions, 58 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 7ba05fc553a..a9959195654 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -51,17 +51,6 @@ void gfs2_inode_attr_in(struct gfs2_inode *ip) | |||
51 | struct gfs2_dinode_host *di = &ip->i_di; | 51 | struct gfs2_dinode_host *di = &ip->i_di; |
52 | 52 | ||
53 | inode->i_ino = ip->i_num.no_addr; | 53 | inode->i_ino = ip->i_num.no_addr; |
54 | |||
55 | switch (di->di_mode & S_IFMT) { | ||
56 | case S_IFBLK: | ||
57 | case S_IFCHR: | ||
58 | inode->i_rdev = MKDEV(di->di_major, di->di_minor); | ||
59 | break; | ||
60 | default: | ||
61 | inode->i_rdev = 0; | ||
62 | break; | ||
63 | }; | ||
64 | |||
65 | inode->i_mode = di->di_mode; | 54 | inode->i_mode = di->di_mode; |
66 | inode->i_nlink = di->di_nlink; | 55 | inode->i_nlink = di->di_nlink; |
67 | inode->i_uid = di->di_uid; | 56 | inode->i_uid = di->di_uid; |
@@ -222,6 +211,15 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) | |||
222 | return -ESTALE; | 211 | return -ESTALE; |
223 | 212 | ||
224 | di->di_mode = be32_to_cpu(str->di_mode); | 213 | di->di_mode = be32_to_cpu(str->di_mode); |
214 | ip->i_inode.i_rdev = 0; | ||
215 | switch (di->di_mode & S_IFMT) { | ||
216 | case S_IFBLK: | ||
217 | case S_IFCHR: | ||
218 | ip->i_inode.i_rdev = MKDEV(be32_to_cpu(str->di_major), | ||
219 | be32_to_cpu(str->di_minor)); | ||
220 | break; | ||
221 | }; | ||
222 | |||
225 | di->di_uid = be32_to_cpu(str->di_uid); | 223 | di->di_uid = be32_to_cpu(str->di_uid); |
226 | di->di_gid = be32_to_cpu(str->di_gid); | 224 | di->di_gid = be32_to_cpu(str->di_gid); |
227 | di->di_nlink = be32_to_cpu(str->di_nlink); | 225 | di->di_nlink = be32_to_cpu(str->di_nlink); |
@@ -230,8 +228,6 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) | |||
230 | di->di_atime = be64_to_cpu(str->di_atime); | 228 | di->di_atime = be64_to_cpu(str->di_atime); |
231 | di->di_mtime = be64_to_cpu(str->di_mtime); | 229 | di->di_mtime = be64_to_cpu(str->di_mtime); |
232 | di->di_ctime = be64_to_cpu(str->di_ctime); | 230 | di->di_ctime = be64_to_cpu(str->di_ctime); |
233 | di->di_major = be32_to_cpu(str->di_major); | ||
234 | di->di_minor = be32_to_cpu(str->di_minor); | ||
235 | 231 | ||
236 | di->di_goal_meta = be64_to_cpu(str->di_goal_meta); | 232 | di->di_goal_meta = be64_to_cpu(str->di_goal_meta); |
237 | di->di_goal_data = be64_to_cpu(str->di_goal_data); | 233 | di->di_goal_data = be64_to_cpu(str->di_goal_data); |
@@ -270,7 +266,6 @@ int gfs2_inode_refresh(struct gfs2_inode *ip) | |||
270 | } | 266 | } |
271 | 267 | ||
272 | error = gfs2_dinode_in(ip, dibh->b_data); | 268 | error = gfs2_dinode_in(ip, dibh->b_data); |
273 | |||
274 | brelse(dibh); | 269 | brelse(dibh); |
275 | ip->i_vn = ip->i_gl->gl_vn; | 270 | ip->i_vn = ip->i_gl->gl_vn; |
276 | 271 | ||
@@ -684,7 +679,7 @@ out: | |||
684 | static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | 679 | static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, |
685 | const struct gfs2_inum_host *inum, unsigned int mode, | 680 | const struct gfs2_inum_host *inum, unsigned int mode, |
686 | unsigned int uid, unsigned int gid, | 681 | unsigned int uid, unsigned int gid, |
687 | const u64 *generation) | 682 | const u64 *generation, dev_t dev) |
688 | { | 683 | { |
689 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); | 684 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
690 | struct gfs2_dinode *di; | 685 | struct gfs2_dinode *di; |
@@ -705,7 +700,8 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | |||
705 | di->di_size = cpu_to_be64(0); | 700 | di->di_size = cpu_to_be64(0); |
706 | di->di_blocks = cpu_to_be64(1); | 701 | di->di_blocks = cpu_to_be64(1); |
707 | di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(get_seconds()); | 702 | di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(get_seconds()); |
708 | di->di_major = di->di_minor = cpu_to_be32(0); | 703 | di->di_major = cpu_to_be32(MAJOR(dev)); |
704 | di->di_minor = cpu_to_be32(MINOR(dev)); | ||
709 | di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr); | 705 | di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr); |
710 | di->di_generation = cpu_to_be64(*generation); | 706 | di->di_generation = cpu_to_be64(*generation); |
711 | di->di_flags = cpu_to_be32(0); | 707 | di->di_flags = cpu_to_be32(0); |
@@ -740,7 +736,7 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | |||
740 | 736 | ||
741 | static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | 737 | static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, |
742 | unsigned int mode, const struct gfs2_inum_host *inum, | 738 | unsigned int mode, const struct gfs2_inum_host *inum, |
743 | const u64 *generation) | 739 | const u64 *generation, dev_t dev) |
744 | { | 740 | { |
745 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); | 741 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
746 | unsigned int uid, gid; | 742 | unsigned int uid, gid; |
@@ -761,7 +757,7 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | |||
761 | if (error) | 757 | if (error) |
762 | goto out_quota; | 758 | goto out_quota; |
763 | 759 | ||
764 | init_dinode(dip, gl, inum, mode, uid, gid, generation); | 760 | init_dinode(dip, gl, inum, mode, uid, gid, generation, dev); |
765 | gfs2_quota_change(dip, +1, uid, gid); | 761 | gfs2_quota_change(dip, +1, uid, gid); |
766 | gfs2_trans_end(sdp); | 762 | gfs2_trans_end(sdp); |
767 | 763 | ||
@@ -892,7 +888,7 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip) | |||
892 | */ | 888 | */ |
893 | 889 | ||
894 | struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, | 890 | struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, |
895 | unsigned int mode) | 891 | unsigned int mode, dev_t dev) |
896 | { | 892 | { |
897 | struct inode *inode; | 893 | struct inode *inode; |
898 | struct gfs2_inode *dip = ghs->gh_gl->gl_object; | 894 | struct gfs2_inode *dip = ghs->gh_gl->gl_object; |
@@ -950,7 +946,7 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, | |||
950 | goto fail_gunlock; | 946 | goto fail_gunlock; |
951 | } | 947 | } |
952 | 948 | ||
953 | error = make_dinode(dip, ghs[1].gh_gl, mode, &inum, &generation); | 949 | error = make_dinode(dip, ghs[1].gh_gl, mode, &inum, &generation, dev); |
954 | if (error) | 950 | if (error) |
955 | goto fail_gunlock2; | 951 | goto fail_gunlock2; |
956 | 952 | ||
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index d699b920975..33c9ea68f7e 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h | |||
@@ -37,7 +37,7 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff); | |||
37 | struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, | 37 | struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, |
38 | int is_root, struct nameidata *nd); | 38 | int is_root, struct nameidata *nd); |
39 | struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, | 39 | struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, |
40 | unsigned int mode); | 40 | unsigned int mode, dev_t dev); |
41 | int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name, | 41 | int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name, |
42 | struct gfs2_inode *ip); | 42 | struct gfs2_inode *ip); |
43 | int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name, | 43 | int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name, |
diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index 4bc590edb60..60dd943761a 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c | |||
@@ -170,8 +170,6 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) | |||
170 | str->di_atime = cpu_to_be64(di->di_atime); | 170 | str->di_atime = cpu_to_be64(di->di_atime); |
171 | str->di_mtime = cpu_to_be64(di->di_mtime); | 171 | str->di_mtime = cpu_to_be64(di->di_mtime); |
172 | str->di_ctime = cpu_to_be64(di->di_ctime); | 172 | str->di_ctime = cpu_to_be64(di->di_ctime); |
173 | str->di_major = cpu_to_be32(di->di_major); | ||
174 | str->di_minor = cpu_to_be32(di->di_minor); | ||
175 | 173 | ||
176 | str->di_goal_meta = cpu_to_be64(di->di_goal_meta); | 174 | str->di_goal_meta = cpu_to_be64(di->di_goal_meta); |
177 | str->di_goal_data = cpu_to_be64(di->di_goal_data); | 175 | str->di_goal_data = cpu_to_be64(di->di_goal_data); |
@@ -202,8 +200,6 @@ void gfs2_dinode_print(const struct gfs2_inode *ip) | |||
202 | printk(KERN_INFO " di_atime = %lld\n", (long long)di->di_atime); | 200 | printk(KERN_INFO " di_atime = %lld\n", (long long)di->di_atime); |
203 | printk(KERN_INFO " di_mtime = %lld\n", (long long)di->di_mtime); | 201 | printk(KERN_INFO " di_mtime = %lld\n", (long long)di->di_mtime); |
204 | printk(KERN_INFO " di_ctime = %lld\n", (long long)di->di_ctime); | 202 | printk(KERN_INFO " di_ctime = %lld\n", (long long)di->di_ctime); |
205 | pv(di, di_major, "%u"); | ||
206 | pv(di, di_minor, "%u"); | ||
207 | 203 | ||
208 | printk(KERN_INFO " di_goal_meta = %llu\n", (unsigned long long)di->di_goal_meta); | 204 | printk(KERN_INFO " di_goal_meta = %llu\n", (unsigned long long)di->di_goal_meta); |
209 | printk(KERN_INFO " di_goal_data = %llu\n", (unsigned long long)di->di_goal_data); | 205 | printk(KERN_INFO " di_goal_data = %llu\n", (unsigned long long)di->di_goal_data); |
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index b2c2fe613d7..c10b914bf8c 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c | |||
@@ -59,7 +59,7 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry, | |||
59 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); | 59 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); |
60 | 60 | ||
61 | for (;;) { | 61 | for (;;) { |
62 | inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode); | 62 | inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode, 0); |
63 | if (!IS_ERR(inode)) { | 63 | if (!IS_ERR(inode)) { |
64 | gfs2_trans_end(sdp); | 64 | gfs2_trans_end(sdp); |
65 | if (dip->i_alloc.al_rgd) | 65 | if (dip->i_alloc.al_rgd) |
@@ -326,7 +326,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry, | |||
326 | 326 | ||
327 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); | 327 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); |
328 | 328 | ||
329 | inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO); | 329 | inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO, 0); |
330 | if (IS_ERR(inode)) { | 330 | if (IS_ERR(inode)) { |
331 | gfs2_holder_uninit(ghs); | 331 | gfs2_holder_uninit(ghs); |
332 | return PTR_ERR(inode); | 332 | return PTR_ERR(inode); |
@@ -379,7 +379,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
379 | 379 | ||
380 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); | 380 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); |
381 | 381 | ||
382 | inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode); | 382 | inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode, 0); |
383 | if (IS_ERR(inode)) { | 383 | if (IS_ERR(inode)) { |
384 | gfs2_holder_uninit(ghs); | 384 | gfs2_holder_uninit(ghs); |
385 | return PTR_ERR(inode); | 385 | return PTR_ERR(inode); |
@@ -504,47 +504,19 @@ out: | |||
504 | static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, | 504 | static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, |
505 | dev_t dev) | 505 | dev_t dev) |
506 | { | 506 | { |
507 | struct gfs2_inode *dip = GFS2_I(dir), *ip; | 507 | struct gfs2_inode *dip = GFS2_I(dir); |
508 | struct gfs2_sbd *sdp = GFS2_SB(dir); | 508 | struct gfs2_sbd *sdp = GFS2_SB(dir); |
509 | struct gfs2_holder ghs[2]; | 509 | struct gfs2_holder ghs[2]; |
510 | struct inode *inode; | 510 | struct inode *inode; |
511 | struct buffer_head *dibh; | ||
512 | u32 major = 0, minor = 0; | ||
513 | int error; | ||
514 | |||
515 | switch (mode & S_IFMT) { | ||
516 | case S_IFBLK: | ||
517 | case S_IFCHR: | ||
518 | major = MAJOR(dev); | ||
519 | minor = MINOR(dev); | ||
520 | break; | ||
521 | case S_IFIFO: | ||
522 | case S_IFSOCK: | ||
523 | break; | ||
524 | default: | ||
525 | return -EOPNOTSUPP; | ||
526 | }; | ||
527 | 511 | ||
528 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); | 512 | gfs2_holder_init(dip->i_gl, 0, 0, ghs); |
529 | 513 | ||
530 | inode = gfs2_createi(ghs, &dentry->d_name, mode); | 514 | inode = gfs2_createi(ghs, &dentry->d_name, mode, dev); |
531 | if (IS_ERR(inode)) { | 515 | if (IS_ERR(inode)) { |
532 | gfs2_holder_uninit(ghs); | 516 | gfs2_holder_uninit(ghs); |
533 | return PTR_ERR(inode); | 517 | return PTR_ERR(inode); |
534 | } | 518 | } |
535 | 519 | ||
536 | ip = ghs[1].gh_gl->gl_object; | ||
537 | |||
538 | ip->i_di.di_major = major; | ||
539 | ip->i_di.di_minor = minor; | ||
540 | |||
541 | error = gfs2_meta_inode_buffer(ip, &dibh); | ||
542 | |||
543 | if (!gfs2_assert_withdraw(sdp, !error)) { | ||
544 | gfs2_dinode_out(ip, dibh->b_data); | ||
545 | brelse(dibh); | ||
546 | } | ||
547 | |||
548 | gfs2_trans_end(sdp); | 520 | gfs2_trans_end(sdp); |
549 | if (dip->i_alloc.al_rgd) | 521 | if (dip->i_alloc.al_rgd) |
550 | gfs2_inplace_release(dip); | 522 | gfs2_inplace_release(dip); |