From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] libgfs2: Add iovec to gfs2_buffer_head
Date: Fri, 16 Dec 2011 20:25:22 +0000 [thread overview]
Message-ID: <4EEBA932.1080006@redhat.com> (raw)
In-Reply-To: <1324045467.2740.2.camel@menhir>
Hi,
On 16/12/11 14:24, Steven Whitehouse wrote:
>
> So that we keep track of buffer sizes, add an iovec to the
> gfs2_buffer_head structure. This uses an unnamed union in
> order to be backwards compatible with users of b_data.
>
> Signed-off-by: Steven Whitehouse<swhiteho@redhat.com>
Looks good to me,
Andy
>
> diff --git a/gfs2/libgfs2/buf.c b/gfs2/libgfs2/buf.c
> index 445b0ba..956dd8b 100644
> --- a/gfs2/libgfs2/buf.c
> +++ b/gfs2/libgfs2/buf.c
> @@ -24,7 +24,9 @@ struct gfs2_buffer_head *bget(struct gfs2_sbd *sdp, uint64_t num)
>
> bh->b_blocknr = num;
> bh->sdp = sdp;
> - bh->b_data = (char *)bh + sizeof(struct gfs2_buffer_head);
> + bh->iov.iov_base = (char *)bh + sizeof(struct gfs2_buffer_head);
> + bh->iov.iov_len = sdp->bsize;
> +
> return bh;
> }
>
> @@ -42,7 +44,7 @@ struct gfs2_buffer_head *__bread(struct gfs2_sbd *sdp, uint64_t num, int line,
> (unsigned long long)num);
> exit(-1);
> }
> - if (read(sdp->device_fd, bh->b_data, sdp->bsize)< 0) {
> + if (readv(sdp->device_fd,&bh->iov, 1)< 0) {
> fprintf(stderr, "bad read: %s from %s:%d: block "
> "%llu (0x%llx)\n", strerror(errno),
> caller, line, (unsigned long long)num,
> @@ -60,7 +62,7 @@ int bwrite(struct gfs2_buffer_head *bh)
> bh->b_blocknr * sdp->bsize) {
> return -1;
> }
> - if (write(sdp->device_fd, bh->b_data, sdp->bsize) != sdp->bsize)
> + if (writev(sdp->device_fd,&bh->iov, 1) != bh->iov.iov_len)
> return -1;
> sdp->writes++;
> bh->b_modified = 0;
> diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
> index 0e521fb..d5cac5a 100644
> --- a/gfs2/libgfs2/libgfs2.h
> +++ b/gfs2/libgfs2/libgfs2.h
> @@ -7,6 +7,7 @@
> #include<errno.h>
> #include<sys/types.h>
> #include<sys/stat.h>
> +#include<sys/uio.h>
> #include<linux/types.h>
> #include<linux/limits.h>
> #include<endian.h>
> @@ -111,7 +112,10 @@ struct gfs2_buffer_head {
> osi_list_t b_altlist; /* alternate list */
> uint64_t b_blocknr;
> int b_modified;
> - char *b_data;
> + union {
> + char *b_data;
> + struct iovec iov;
> + };
> struct gfs2_sbd *sdp;
> };
>
>
>
prev parent reply other threads:[~2011-12-16 20:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-16 14:24 [Cluster-devel] libgfs2: Add iovec to gfs2_buffer_head Steven Whitehouse
2011-12-16 20:25 ` Andrew Price [this message]
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=4EEBA932.1080006@redhat.com \
--to=anprice@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).