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:13 PM
Bob Peterson
 
Default libgfs2: eliminate gfs1_readi in favor of gfs2_readi

>From b3a08a2127d565609c0edaba400525b8737ab324 Mon Sep 17 00:00:00 2001
From: Bob Peterson <rpeterso@redhat.com>
Date: Wed, 10 Aug 2011 10:21:00 -0500
Subject: [PATCH 32/44] libgfs2: eliminate gfs1_readi in favor of gfs2_readi

This patch eliminates function gfs1_readi because it's nearly
identical to gfs2_readi. The gfs1-specific bits have been made
generic in gfs2_readi based on the sdp->gfs1 setting.

rhbz#675723
---
gfs2/edit/extended.c | 7 +----
gfs2/libgfs2/fs_ops.c | 21 ++++++++++----
gfs2/libgfs2/gfs1.c | 68 +-----------------------------------------------
gfs2/libgfs2/libgfs2.h | 2 -
gfs2/libgfs2/super.c | 4 ---
5 files changed, 17 insertions(+), 85 deletions(-)

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 47938e4..3acd507 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -516,12 +516,7 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)

roff = print_entry_ndx * risize(&sbd);

- if (sbd.gfs1)
- error = gfs1_readi(dip, (void *)&rbuf, roff,
- risize(&sbd));
- else
- error = gfs2_readi(dip, (void *)&rbuf, roff,
- risize(&sbd));
+ error = gfs2_readi(dip, (void *)&rbuf, roff, risize(&sbd));
if (!error) /* end of file */
break;
gfs2_rindex_in(&ri, rbuf);
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 60ee467..4c8d31e 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -510,6 +510,7 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
unsigned int amount;
int not_new = 0;
int isdir = !!(S_ISDIR(ip->i_di.di_mode));
+ int journaled = ip->i_di.di_flags & GFS2_DIF_JDATA;
int copied = 0;

if (offset >= ip->i_di.di_size)
@@ -521,7 +522,7 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
if (!size)
return 0;

- if (isdir) {
+ if ((sdp->gfs1 && journaled) || (!sdp->gfs1 && isdir)) {
lblock = offset;
o = lblock % sdp->sd_jbsize;
lblock /= sdp->sd_jbsize;
@@ -532,7 +533,7 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,

if (inode_is_stuffed(ip))
o += sizeof(struct gfs2_dinode);
- else if (isdir)
+ else if ((sdp->gfs1 && journaled) || (!sdp->gfs1 && isdir))
o += sizeof(struct gfs2_meta_header);

while (copied < size) {
@@ -540,9 +541,14 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
if (amount > sdp->bsize - o)
amount = sdp->bsize - o;

- if (!extlen)
- block_map(ip, lblock, &not_new, &dblock, &extlen,
- FALSE);
+ if (!extlen) {
+ if (sdp->gfs1)
+ gfs1_block_map(ip, lblock, &not_new, &dblock,
+ &extlen, FALSE);
+ else
+ block_map(ip, lblock, &not_new, &dblock,
+ &extlen, FALSE);
+ }

if (dblock) {
if (dblock == ip->i_di.di_num.no_addr)
@@ -561,7 +567,10 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
copied += amount;
lblock++;

- o = (isdir) ? sizeof(struct gfs2_meta_header) : 0;
+ if (sdp->gfs1)
+ o = (journaled) ? sizeof(struct gfs2_meta_header) : 0;
+ else
+ o = (isdir) ? sizeof(struct gfs2_meta_header) : 0;
}

return copied;
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 66e00ff..dc29006 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -156,72 +156,6 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
free(mp);
}

-int gfs1_readi(struct gfs2_inode *ip, void *bufin,
- uint64_t offset, unsigned int size)
-{
- struct gfs2_sbd *sdp = ip->i_sbd;
- struct gfs2_buffer_head *bh;
- uint64_t lblock, dblock = 0;
- uint32_t extlen = 0;
- unsigned int amount;
- int not_new = 0;
- int journaled = fs_is_jdata(ip);
- int copied = 0;
- char *buf = bufin;
-
- if (offset >= ip->i_di.di_size)
- return 0;
-
- if ((offset + size) > ip->i_di.di_size)
- size = ip->i_di.di_size - offset;
-
- if (!size)
- return 0;
-
- if (journaled) {
- lblock = offset / sdp->sd_jbsize;
- offset %= sdp->sd_jbsize;
- } else {
- lblock = offset >> sdp->sd_sb.sb_bsize_shift;
- offset &= sdp->sd_sb.sb_bsize - 1;
- }
-
- if (!ip->i_di.di_height) /* stuffed */
- offset += sizeof(struct gfs_dinode);
- else if (journaled)
- offset += sizeof(struct gfs2_meta_header);
-
- while (copied < size) {
- amount = size - copied;
- if (amount > sdp->bsize - offset)
- amount = sdp->bsize - offset;
-
- if (!extlen)
- gfs1_block_map(ip, lblock, &not_new, &dblock,
- &extlen, FALSE);
-
- if (dblock) {
- bh = bread(sdp, dblock);
- dblock++;
- extlen--;
- } else
- bh = NULL;
-
-
- if (bh) {
- memcpy(buf+copied, bh->b_data + offset, amount);
- brelse(bh);
- } else
- memset(buf+copied, 0, amount);
- copied += amount;
- lblock++;
-
- offset = (journaled) ? sizeof(struct gfs2_meta_header) : 0;
- }
-
- return copied;
-}
-
/**
* gfs1_rindex_read - read in the rg index file
* Stolen from libgfs2/super.c, but modified to handle gfs1.
@@ -246,7 +180,7 @@ int gfs1_rindex_read(struct gfs2_sbd *sdp, int fd, int *count1)
if (fd > 0)
error = read(fd, &buf, sizeof(struct gfs2_rindex));
else
- error = gfs1_readi(sdp->md.riinode, (char *)&buf,
+ error = gfs2_readi(sdp->md.riinode, (char *)&buf,
(rg * sizeof(struct gfs2_rindex)),
sizeof(struct gfs2_rindex));
if (!error)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index d418d2f..e75c83a 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -669,8 +669,6 @@ extern void gfs1_lookup_block(struct gfs2_inode *ip,
int create, int *new, uint64_t *block);
extern void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
uint64_t *dblock, uint32_t *extlen, int prealloc);
-extern int gfs1_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
- unsigned int size);
extern int gfs1_rindex_read(struct gfs2_sbd *sdp, int fd, int *count1);
extern int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet);
extern struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 4b53299..61425aa 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -169,10 +169,6 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane)
for (rg = 0; ; rg++) {
if (fd > 0)
error = read(fd, &buf, risize(sdp));
- else if (sdp->gfs1)
- error = gfs1_readi(sdp->md.riinode,
- (char *)&buf.bufgfs1,
- rg * risize(sdp), risize(sdp));
else
error = gfs2_readi(sdp->md.riinode,
(char *)&buf.bufgfs2,
--
1.7.4.4
 
Old 01-20-2012, 02:10 PM
 
Default libgfs2: eliminate gfs1_readi in favor of gfs2_readi

From: Bob Peterson <rpeterso@redhat.com>

This patch eliminates function gfs1_readi because it's nearly
identical to gfs2_readi. The gfs1-specific bits have been made
generic in gfs2_readi based on the sdp->gfs1 setting.

rhbz#675723
---
gfs2/edit/extended.c | 8 +----
gfs2/libgfs2/fs_ops.c | 21 ++++++++++----
gfs2/libgfs2/gfs1.c | 68 +-----------------------------------------------
gfs2/libgfs2/libgfs2.h | 2 -
gfs2/libgfs2/super.c | 5 ---
5 files changed, 18 insertions(+), 86 deletions(-)

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 366dfc6..6326ec3 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -515,12 +515,8 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)

roff = print_entry_ndx * sizeof(struct gfs2_rindex);

- if (sbd.gfs1)
- error = gfs1_readi(dip, (void *)&rbuf, roff,
- sizeof(struct gfs2_rindex));
- else
- error = gfs2_readi(dip, (void *)&rbuf, roff,
- sizeof(struct gfs2_rindex));
+ error = gfs2_readi(dip, (void *)&rbuf, roff,
+ sizeof(struct gfs2_rindex));
if (!error) /* end of file */
break;
gfs2_rindex_in(&ri, rbuf);
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 3d57b97..6ffee9d 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -508,6 +508,7 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
unsigned int amount;
int not_new = 0;
int isdir = !!(S_ISDIR(ip->i_di.di_mode));
+ int journaled = ip->i_di.di_flags & GFS2_DIF_JDATA;
int copied = 0;

if (offset >= ip->i_di.di_size)
@@ -519,7 +520,7 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
if (!size)
return 0;

- if (isdir) {
+ if ((sdp->gfs1 && journaled) || (!sdp->gfs1 && isdir)) {
lblock = offset;
o = lblock % sdp->sd_jbsize;
lblock /= sdp->sd_jbsize;
@@ -530,7 +531,7 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,

if (inode_is_stuffed(ip))
o += sizeof(struct gfs2_dinode);
- else if (isdir)
+ else if ((sdp->gfs1 && journaled) || (!sdp->gfs1 && isdir))
o += sizeof(struct gfs2_meta_header);

while (copied < size) {
@@ -538,9 +539,14 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
if (amount > sdp->bsize - o)
amount = sdp->bsize - o;

- if (!extlen)
- block_map(ip, lblock, &not_new, &dblock, &extlen,
- FALSE);
+ if (!extlen) {
+ if (sdp->gfs1)
+ gfs1_block_map(ip, lblock, &not_new, &dblock,
+ &extlen, FALSE);
+ else
+ block_map(ip, lblock, &not_new, &dblock,
+ &extlen, FALSE);
+ }

if (dblock) {
if (dblock == ip->i_di.di_num.no_addr)
@@ -559,7 +565,10 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
copied += amount;
lblock++;

- o = (isdir) ? sizeof(struct gfs2_meta_header) : 0;
+ if (sdp->gfs1)
+ o = (journaled) ? sizeof(struct gfs2_meta_header) : 0;
+ else
+ o = (isdir) ? sizeof(struct gfs2_meta_header) : 0;
}

return copied;
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 5018334..2bdf57f 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -154,72 +154,6 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
free(mp);
}

-int gfs1_readi(struct gfs2_inode *ip, void *bufin,
- uint64_t offset, unsigned int size)
-{
- struct gfs2_sbd *sdp = ip->i_sbd;
- struct gfs2_buffer_head *bh;
- uint64_t lblock, dblock = 0;
- uint32_t extlen = 0;
- unsigned int amount;
- int not_new = 0;
- int journaled = fs_is_jdata(ip);
- int copied = 0;
- char *buf = bufin;
-
- if (offset >= ip->i_di.di_size)
- return 0;
-
- if ((offset + size) > ip->i_di.di_size)
- size = ip->i_di.di_size - offset;
-
- if (!size)
- return 0;
-
- if (journaled) {
- lblock = offset / sdp->sd_jbsize;
- offset %= sdp->sd_jbsize;
- } else {
- lblock = offset >> sdp->sd_sb.sb_bsize_shift;
- offset &= sdp->sd_sb.sb_bsize - 1;
- }
-
- if (!ip->i_di.di_height) /* stuffed */
- offset += sizeof(struct gfs_dinode);
- else if (journaled)
- offset += sizeof(struct gfs2_meta_header);
-
- while (copied < size) {
- amount = size - copied;
- if (amount > sdp->bsize - offset)
- amount = sdp->bsize - offset;
-
- if (!extlen)
- gfs1_block_map(ip, lblock, &not_new, &dblock,
- &extlen, FALSE);
-
- if (dblock) {
- bh = bread(sdp, dblock);
- dblock++;
- extlen--;
- } else
- bh = NULL;
-
-
- if (bh) {
- memcpy(buf+copied, bh->b_data + offset, amount);
- brelse(bh);
- } else
- memset(buf+copied, 0, amount);
- copied += amount;
- lblock++;
-
- offset = (journaled) ? sizeof(struct gfs2_meta_header) : 0;
- }
-
- return copied;
-}
-
/**
* gfs1_rindex_read - read in the rg index file
* Stolen from libgfs2/super.c, but modified to handle gfs1.
@@ -244,7 +178,7 @@ int gfs1_rindex_read(struct gfs2_sbd *sdp, int fd, int *count1)
if (fd > 0)
error = read(fd, &buf, sizeof(struct gfs2_rindex));
else
- error = gfs1_readi(sdp->md.riinode, (char *)&buf,
+ error = gfs2_readi(sdp->md.riinode, (char *)&buf,
(rg * sizeof(struct gfs2_rindex)),
sizeof(struct gfs2_rindex));
if (!error)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 9bae01b..cc71bd3 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -665,8 +665,6 @@ extern void gfs1_lookup_block(struct gfs2_inode *ip,
int create, int *new, uint64_t *block);
extern void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
uint64_t *dblock, uint32_t *extlen, int prealloc);
-extern int gfs1_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
- unsigned int size);
extern int gfs1_rindex_read(struct gfs2_sbd *sdp, int fd, int *count1);
extern int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet);
extern struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index d902ba2..0fac740 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -158,11 +158,6 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane)
for (rg = 0; ; rg++) {
if (fd > 0)
error = read(fd, &buf, sizeof(struct gfs2_rindex));
- else if (sdp->gfs1)
- error = gfs1_readi(sdp->md.riinode,
- (char *)&buf.bufgfs1,
- rg * sizeof(struct gfs2_rindex),
- sizeof(struct gfs2_rindex));
else
error = gfs2_readi(sdp->md.riinode,
(char *)&buf.bufgfs2,
--
1.7.7.5
 

Thread Tools




All times are GMT. The time now is 11:35 AM.

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