From: rpeterso@redhat.com <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 32/66] libgfs2: eliminate gfs1_readi in favor of gfs2_readi
Date: Fri, 20 Jan 2012 09:10:13 -0600 [thread overview]
Message-ID: <1327072247-26275-33-git-send-email-rpeterso@redhat.com> (raw)
In-Reply-To: <1327072247-26275-1-git-send-email-rpeterso@redhat.com>
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, ¬_new, &dblock, &extlen,
- FALSE);
+ if (!extlen) {
+ if (sdp->gfs1)
+ gfs1_block_map(ip, lblock, ¬_new, &dblock,
+ &extlen, FALSE);
+ else
+ block_map(ip, lblock, ¬_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, ¬_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
next prev parent reply other threads:[~2012-01-20 15:10 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-20 15:09 [Cluster-devel] [PATCH 00/66] fsck.gfs2: add ability to fix GFS (gfs1) file systems rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 01/66] fsck.gfs2: Make functions use sdp rather than sbp rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 02/66] fsck.gfs2: Change "if(" to "if (" rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 03/66] libgfs1: Add gfs1 variable to superblock structure rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 04/66] libgfs2: Make check_sb and read_sb operate on gfs1 rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 05/66] libgfs2: move gfs1 structures to libgfs2 rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 06/66] fsck.gfs2: Check for blocks wrongly inside resource groups rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 07/66] fsck.gfs2: Rename check_leaf to check_ealeaf_block rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 08/66] fsck.gfs2: fsck.gfs2: Delete vestigial buffer_head in check_leaf rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 09/66] fsck.gfs2: fsck.gfs2: Rename nlink functions to be intuitive rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 10/66] fsck.gfs2: fsck.gfs2: Sync di_nlink adding links for lost+found rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 11/66] fsck.gfs2: fsck.gfs2: Make dir entry count 32 bits rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 12/66] fsck.gfs2: get rid of triple negative logic rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 13/66] dirent_repair needs to mark the buffer as modified rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 14/66] fsck.gfs2: fsck.gfs2: Ask to reclaim unlinked meta per-rgrp only rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 15/66] fsck.gfs2: fsck.gfs2: Refactor add_dotdot function in lost+found rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 16/66] libgfs2: libgfs2: Use __FUNCTION__ rather than __FILE__ rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 17/66] fsck.gfs2: fsck.gfs2: Don't stop invalidating blocks on invalid rpeterso
2012-01-20 15:09 ` [Cluster-devel] [PATCH 18/66] fsck.gfs2: fsck.gfs2: Find and clear duplicate leaf blocks refs rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 19/66] fsck.gfs2: fsck.gfs2: Move check_num_ptrs from metawalk to pass1 rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 20/66] fsck.gfs2: fsck.gfs2: Duplicate ref processing for leaf blocks rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 21/66] fsck.gfs2: fsck.gfs2: split check_leaf_blks to be more readable rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 22/66] fsck.gfs2: Shorten output rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 23/66] fsck.gfs2: Make output messages more sensible rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 24/66] fsck.gfs pass2: Refactor function set_dotdot_dir rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 25/66] fsck.gfs2 pass2: Delete extended attributes with inode rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 26/66] fsck.gfs2 pass2: Don't delete invalid inode metadata rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 27/66] fsck.gfs2 pass3: Refactor mark_and_return_parent rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 28/66] fsck.gfs2: misc cosmetic changes rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 29/66] fsck.gfs2: Don't use old_leaf if it was a duplicate rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 30/66] fsck.gfs2: Add find_remove_dup, free_block_if_notdup rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 31/66] fsck.gfs2: don't free prev rgrp list repairing rgrps rpeterso
2012-01-20 15:10 ` rpeterso [this message]
2012-01-20 15:10 ` [Cluster-devel] [PATCH 33/66] libgfs2: Mark buffer modified adding a new GFS1 block rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 34/66] libgfs2: Use dinode buffer to map gfs1 dinode blocks rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 35/66] libgfs2: move block_map functions to fsck.gfs2 rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 36/66] libgfs2: eliminate gfs1_rindex_read rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 37/66] libgfs2: combine ri_update and gfs1_ri_update rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 38/66] libgfs2: combine gfs_inode_read and gfs_inode_get rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 39/66] libgfs2: move gfs1 functions from edit to libgfs2 rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 40/66] gfs2_edit savemeta: save_inode_data backward for gfs1 rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 41/66] libgfs2: expand capabilities to operate on gfs1 rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 42/66] fsck.gfs2: Combine block and char device inode types rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 43/66] fsck.gfs2: four-step duplicate elimination process rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 44/66] fsck.gfs2: Add ability to check gfs1 file systems rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 45/66] fsck.gfs2: Remove bad inodes from duplicate tree rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 46/66] fsck.gfs2: Handle duplicate reference to dinode blocks rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 47/66] fsck.gfs2: Bad extended attributes not deleted properly rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 48/66] libgfs2: Make rebuild functions not re-read ip rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 49/66] fsck.gfs2: Shorten debug output rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 50/66] fsck.gfs2: Increment link count reporting wrong dinode rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 51/66] fsck.gfs2: system dinodes take priority over user dinodes rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 52/66] fsck.gfs2: Recognize partially gfs2-converted dinodes rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 53/66] fsck.gfs2: Print step 2 duplicate debug msg first rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 54/66] fsck.gfs2: pass1c counts percentage backward rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 55/66] fsck.gfs2: Speed up rangecheck functions rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 56/66] libgfs2: Make in-core rgrps use rbtree rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 57/66] fsck.gfs2: Fix memory leaks rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 58/66] Change man pages and gfs2_convert messages to include GFS rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 59/66] gfs2_edit: Fix memory leaks rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 60/66] fsck.gfs2: Journals not properly checked rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 61/66] fsck.gfs2: Rearrange block types to group all inode types rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 62/66] fsck.gfs2: Fix initialization error return codes rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 63/66] fsck.gfs2: Don't use strerror for libgfs2 errors rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 64/66] fsck.gfs2: Fix memory leak in initialize.c rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 65/66] fsck.gfs2: Add return code checks and initializations rpeterso
2012-01-20 15:10 ` [Cluster-devel] [PATCH 66/66] libgfs2: Fix null pointer dereference in linked_leaf_search rpeterso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327072247-26275-33-git-send-email-rpeterso@redhat.com \
--to=rpeterso@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).