Re: [PATCH 15/30] db: separate out straight buffer IO from map based IO.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 30, 2013 at 03:31:06PM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@xxxxxxxxxx>
> 
> First step in converting to libxfs based IO.
> 
> Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>

The patch description is a little too short, there's not real
explanation of what it actually does.

> -	if (read_bbs(XFS_SB_DADDR, 1, &bufp, NULL)) {
> +	if (read_buf(XFS_SB_DADDR, 1, bufp)) {

E.g. why isn't this already using the normal libxfs routines?

(there probably is an explanation but I don't quite see it yet..)

>  int
> +read_buf(
> +	xfs_daddr_t	bbno,
> +	int		count,
> +	void		*bufp)
> +{

Is read_buf really a good name for something that is a trivial pread
wrapper and doesn't deal with buffers?  Should the function have some
comments explaining when to use it?  The same also applies to the write
side.

> +	int		err;
> +
> +	err = pwrite64(x.dfd, bufp, BBTOB(count), BBTOB(bbno));
> +	if (err < 0)
> +		err = errno;
> +	else if (err < count)
> +		err = -1;
> +	return err;
> +}

> +static void
> +write_cur_buf(void)
> +{
> +	int ret;
> +
> +	ret = write_buf(iocur_top->bb, iocur_top->blen, iocur_top->buf);
> +
> +	if (ret == -1)
> +		dbprintf(_("incomplete write, block: %lld\n"),
> +			 (iocur_base + iocur_sp)->bb);
> +	else if (ret != 0)
> +		dbprintf(_("write error: %s\n"), strerror(ret));
> +
> +	/* re-read buffer from disk */
> +	ret = read_buf(iocur_top->bb, iocur_top->blen, iocur_top->buf);
> +	if (ret == -1)
> +		dbprintf(_("incomplete read, block: %lld\n"),
> +			 (iocur_base + iocur_sp)->bb);
> +	else if (ret != 0)
> +		dbprintf(_("read error: %s\n"), strerror(ret));
> +}

What is the point of the write and re-read cycle?

> +	for (j = 0; j < count; j++) {
> +		bbno = bbmap->b[j];
>  		if (lseek64(x.dfd, bbno << BBSHIFT, SEEK_SET) < 0) {
>  			rval = errno;
>  			dbprintf(_("can't seek in filesystem at bb %lld\n"), bbno);
>  			return rval;
>  		}
> -		c = BBTOB(bbmap ? 1 : count);
> +		c = BBTOB(1);
>  		i = (int)write(x.dfd, (char *)bufp + BBTOB(j), c);

Shoiuldn't this use the write_buf helper above?

> +	for (j = 0; j < count; j++) {
> +		bbno = bbmap->b[j];
>  		if (lseek64(x.dfd, bbno << BBSHIFT, SEEK_SET) < 0) {
>  			rval = errno;
>  			dbprintf(_("can't seek in filesystem at bb %lld\n"), bbno);
> @@ -483,7 +534,7 @@ read_bbs(
>  				xfree(buf);
>  			buf = NULL;
>  		} else {
> -			c = BBTOB(bbmap ? 1 : count);
> +			c = BBTOB(1);
>  			i = (int)read(x.dfd, (char *)buf + BBTOB(j), c);

And read_buf here?

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux