FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 08-11-2011, 09:15 PM
Bob Peterson
 
Default libgfs2: combine gfs_inode_read and gfs_inode_get

>From a839d64d24bd61c951177e981a88e678912a495f Mon Sep 17 00:00:00 2001
From: Bob Peterson <rpeterso@redhat.com>
Date: Wed, 10 Aug 2011 14:49:35 -0500
Subject: [PATCH 38/44] libgfs2: combine gfs_inode_read and gfs_inode_get

Functions gfs_inode_read and gfs_inode_get were nearly identical.
They did the same exact thing, but one operated on a buffer passed in
while the other read the buffer from the media. This patch combines
the two into a common function and two replacement stubs.

rhbz#675723
---
gfs2/libgfs2/gfs1.c | 57 +++++++++++++-------------------------------------
1 files changed, 15 insertions(+), 42 deletions(-)

diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 91d3641..c807e80 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -193,8 +193,9 @@ static void gfs_dinode_in(struct gfs_dinode *di, struct gfs2_buffer_head *bh)
di->di_eattr = be64_to_cpu(str->di_eattr);
}

-struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
- struct gfs2_buffer_head *bh)
+static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp,
+ struct gfs2_buffer_head *bh,
+ uint64_t di_addr)
{
struct gfs_dinode gfs1_dinode;
struct gfs2_inode *ip;
@@ -205,6 +206,11 @@ struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
exit(-1);
}

+ ip->bh_owned = 0;
+ if (!bh) {
+ bh = bread(sdp, di_addr);
+ ip->bh_owned = 1;
+ }
gfs_dinode_in(&gfs1_dinode, bh);
memcpy(&ip->i_di.di_header, &gfs1_dinode.di_header,
sizeof(struct gfs2_meta_header));
@@ -232,49 +238,16 @@ struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
ip->i_di.di_eattr = gfs1_dinode.di_eattr;
ip->i_bh = bh;
ip->i_sbd = sdp;
- ip->bh_owned = 0;
return ip;
}

-struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
+struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
+ struct gfs2_buffer_head *bh)
{
- struct gfs_dinode gfs1_dinode;
- struct gfs2_inode *ip;
-
- ip = calloc(1, sizeof(struct gfs2_inode));
- if (ip == NULL) {
- fprintf(stderr, "Out of memory in %s
", __FUNCTION__);
- exit(-1);
- }
-
- ip->i_bh = bread(sdp, di_addr);
- gfs_dinode_in(&gfs1_dinode, ip->i_bh);
- memcpy(&ip->i_di.di_header, &gfs1_dinode.di_header,
- sizeof(struct gfs2_meta_header));
- memcpy(&ip->i_di.di_num, &gfs1_dinode.di_num,
- sizeof(struct gfs2_inum));
- ip->i_di.di_mode = gfs1_dinode.di_mode;
- ip->i_di.di_uid = gfs1_dinode.di_uid;
- ip->i_di.di_gid = gfs1_dinode.di_gid;
- ip->i_di.di_nlink = gfs1_dinode.di_nlink;
- ip->i_di.di_size = gfs1_dinode.di_size;
- ip->i_di.di_blocks = gfs1_dinode.di_blocks;
- ip->i_di.di_atime = gfs1_dinode.di_atime;
- ip->i_di.di_mtime = gfs1_dinode.di_mtime;
- ip->i_di.di_ctime = gfs1_dinode.di_ctime;
- ip->i_di.di_major = gfs1_dinode.di_major;
- ip->i_di.di_minor = gfs1_dinode.di_minor;
- ip->i_di.di_goal_data = gfs1_dinode.di_goal_dblk;
- ip->i_di.di_goal_meta = gfs1_dinode.di_goal_mblk;
- ip->i_di.di_flags = gfs1_dinode.di_flags;
- ip->i_di.di_payload_format = gfs1_dinode.di_payload_format;
- ip->i_di.__pad1 = gfs1_dinode.di_type;
- ip->i_di.di_height = gfs1_dinode.di_height;
- ip->i_di.di_depth = gfs1_dinode.di_depth;
- ip->i_di.di_entries = gfs1_dinode.di_entries;
- ip->i_di.di_eattr = gfs1_dinode.di_eattr;
- ip->i_sbd = sdp;
- ip->bh_owned = 1;
- return ip;
+ return __gfs_inode_get(sdp, bh, 0);
}

+struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
+{
+ return __gfs_inode_get(sdp, NULL, di_addr);
+}
--
1.7.4.4
 
Old 01-20-2012, 02:10 PM
 
Default libgfs2: combine gfs_inode_read and gfs_inode_get

From: Bob Peterson <rpeterso@redhat.com>

Functions gfs_inode_read and gfs_inode_get were nearly identical.
They did the same exact thing, but one operated on a buffer passed in
while the other read the buffer from the media. This patch combines
the two into a common function and two replacement stubs.

rhbz#675723
---
gfs2/libgfs2/gfs1.c | 57 +++++++++++++-------------------------------------
1 files changed, 15 insertions(+), 42 deletions(-)

diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 3e314ce..fb4acab 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -191,8 +191,9 @@ static void gfs_dinode_in(struct gfs_dinode *di, struct gfs2_buffer_head *bh)
di->di_eattr = be64_to_cpu(str->di_eattr);
}

-struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
- struct gfs2_buffer_head *bh)
+static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp,
+ struct gfs2_buffer_head *bh,
+ uint64_t di_addr)
{
struct gfs_dinode gfs1_dinode;
struct gfs2_inode *ip;
@@ -203,6 +204,11 @@ struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
exit(-1);
}

+ ip->bh_owned = 0;
+ if (!bh) {
+ bh = bread(sdp, di_addr);
+ ip->bh_owned = 1;
+ }
gfs_dinode_in(&gfs1_dinode, bh);
memcpy(&ip->i_di.di_header, &gfs1_dinode.di_header,
sizeof(struct gfs2_meta_header));
@@ -230,49 +236,16 @@ struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
ip->i_di.di_eattr = gfs1_dinode.di_eattr;
ip->i_bh = bh;
ip->i_sbd = sdp;
- ip->bh_owned = 0;
return ip;
}

-struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
+struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
+ struct gfs2_buffer_head *bh)
{
- struct gfs_dinode gfs1_dinode;
- struct gfs2_inode *ip;
-
- ip = calloc(1, sizeof(struct gfs2_inode));
- if (ip == NULL) {
- fprintf(stderr, "Out of memory in %s
", __FUNCTION__);
- exit(-1);
- }
-
- ip->i_bh = bread(sdp, di_addr);
- gfs_dinode_in(&gfs1_dinode, ip->i_bh);
- memcpy(&ip->i_di.di_header, &gfs1_dinode.di_header,
- sizeof(struct gfs2_meta_header));
- memcpy(&ip->i_di.di_num, &gfs1_dinode.di_num,
- sizeof(struct gfs2_inum));
- ip->i_di.di_mode = gfs1_dinode.di_mode;
- ip->i_di.di_uid = gfs1_dinode.di_uid;
- ip->i_di.di_gid = gfs1_dinode.di_gid;
- ip->i_di.di_nlink = gfs1_dinode.di_nlink;
- ip->i_di.di_size = gfs1_dinode.di_size;
- ip->i_di.di_blocks = gfs1_dinode.di_blocks;
- ip->i_di.di_atime = gfs1_dinode.di_atime;
- ip->i_di.di_mtime = gfs1_dinode.di_mtime;
- ip->i_di.di_ctime = gfs1_dinode.di_ctime;
- ip->i_di.di_major = gfs1_dinode.di_major;
- ip->i_di.di_minor = gfs1_dinode.di_minor;
- ip->i_di.di_goal_data = gfs1_dinode.di_goal_dblk;
- ip->i_di.di_goal_meta = gfs1_dinode.di_goal_mblk;
- ip->i_di.di_flags = gfs1_dinode.di_flags;
- ip->i_di.di_payload_format = gfs1_dinode.di_payload_format;
- ip->i_di.__pad1 = gfs1_dinode.di_type;
- ip->i_di.di_height = gfs1_dinode.di_height;
- ip->i_di.di_depth = gfs1_dinode.di_depth;
- ip->i_di.di_entries = gfs1_dinode.di_entries;
- ip->i_di.di_eattr = gfs1_dinode.di_eattr;
- ip->i_sbd = sdp;
- ip->bh_owned = 1;
- return ip;
+ return __gfs_inode_get(sdp, bh, 0);
}

+struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
+{
+ return __gfs_inode_get(sdp, NULL, di_addr);
+}
--
1.7.7.5
 

Thread Tools




All times are GMT. The time now is 10:03 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org