From: Eryu Guan <guaneryu@gmail.com>
To: Xiao Yang <yangx.jy@cn.fujitsu.com>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH] src/aiocp.c: Fix buffer alignment
Date: Sun, 12 Aug 2018 23:08:36 +0800 [thread overview]
Message-ID: <20180812150836.GE2791@desktop> (raw)
In-Reply-To: <1533790627-7733-1-git-send-email-yangx.jy@cn.fujitsu.com>
On Thu, Aug 09, 2018 at 12:57:07PM +0800, Xiao Yang wrote:
> In generic/252, aiocp with DIRECT will fail and return EINVAL on
> 4096 sector size block device, because the default 512 alignment
> defined in aiocp is not aligned with 4096.
>
> Please see the following error:
> ----------------------------------------------------------
> read missing bytes expect 8388608 got -22
> ----------------------------------------------------------
>
> aiocp with DIRECT should set a proper alignment if -a option is not
> specified.
>
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
> src/aio-dio-regress/aiocp.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/src/aio-dio-regress/aiocp.c b/src/aio-dio-regress/aiocp.c
> index 7e71cc5..57e9d35 100644
> --- a/src/aio-dio-regress/aiocp.c
> +++ b/src/aio-dio-regress/aiocp.c
> @@ -40,6 +40,8 @@
> #include <errno.h>
> #include <stdlib.h>
> #include <sys/select.h>
> +#include <sys/ioctl.h>
> +#include <sys/mount.h>
>
> #include <libaio.h>
>
> @@ -69,6 +71,28 @@ int alignment = 512; /* buffer alignment */
>
> struct timeval delay; /* delay between i/o */
>
> +static int get_sector_size(void)
> +{
> + int fd, ret;
> + int sector_size;
> + char *name;
> +
> + name = getenv("TEST_DEV");
Hmm, I don't quite like the hardcoded "TEST_DEV", that means if we're
testing against SCRATCH_DEV the alignment is also based on TEST_DEV.
I'd rather do "alignment=`_min_dio_alignment <dev>`" and add
"-a $alignment" options to every aiocp test.
Thanks,
Eryu
> + if (!name)
> + return alignment;
> +
> + fd = open(name, O_RDONLY);
> + if (fd < 0)
> + return alignment;
> +
> + ret = ioctl(fd, BLKSSZGET, §or_size);
> + close(fd);
> + if (ret < 0)
> + return alignment;
> +
> + return sector_size;
> +}
> +
> int init_iocb(int n, int iosize)
> {
> void *buf;
> @@ -259,6 +283,7 @@ int main(int argc, char *const *argv)
> int c;
> extern char *optarg;
> extern int optind, opterr, optopt;
> + int aligned = 0;
>
> while ((c = getopt(argc, argv, "a:b:df:n:s:wzD:")) != -1) {
> char *endp;
> @@ -268,6 +293,7 @@ int main(int argc, char *const *argv)
> alignment = strtol(optarg, &endp, 0);
> alignment = (long)scale_by_kmg((long long)alignment,
> *endp);
> + aligned = 1;
> break;
> case 'f': /* use these open flags */
> if (strcmp(optarg, "LARGEFILE") == 0 ||
> @@ -334,6 +360,10 @@ int main(int argc, char *const *argv)
> srcname = "junkdata";
> dstname = "ff2";
> #endif
> +
> + if (!aligned && (source_open_flag & O_DIRECT))
> + alignment = get_sector_size();
> +
> if (!zero) {
> #ifndef DEBUG
> if ((srcfd = open(srcname = *argv, source_open_flag)) < 0) {
> --
> 1.8.3.1
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-08-12 17:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-09 4:57 [PATCH] src/aiocp.c: Fix buffer alignment Xiao Yang
2018-08-12 15:08 ` Eryu Guan [this message]
2018-08-15 5:41 ` [PATCH v2] " Xiao Yang
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=20180812150836.GE2791@desktop \
--to=guaneryu@gmail.com \
--cc=fstests@vger.kernel.org \
--cc=yangx.jy@cn.fujitsu.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