All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: Han Pingtian <hanpt@linux.vnet.ibm.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [RFC PATCH] regression test for 64bit sendfile	capped	at	2G
Date: Tue, 8 Jul 2014 08:30:34 -0400 (EDT)	[thread overview]
Message-ID: <2026740901.5816308.1404822634671.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1015853559.5800703.1404820547657.JavaMail.zimbra@redhat.com>



----- Original Message -----
> From: "Jan Stancek" <jstancek@redhat.com>
> To: "Han Pingtian" <hanpt@linux.vnet.ibm.com>
> Cc: ltp-list@lists.sourceforge.net
> Sent: Tuesday, 8 July, 2014 1:55:47 PM
> Subject: Re: [LTP] [RFC PATCH] regression test for 64bit sendfile	capped	at	2G
> 
> 
> 
> 
> 
> ----- Original Message -----
> > From: "Jan Stancek" <jstancek@redhat.com>
> > To: "Han Pingtian" <hanpt@linux.vnet.ibm.com>
> > Cc: ltp-list@lists.sourceforge.net
> > Sent: Tuesday, 8 July, 2014 12:36:27 PM
> > Subject: Re: [LTP] [RFC PATCH] regression test for 64bit sendfile capped	at
> > 	2G
> > 
> > 
> > 
> > ----- Original Message -----
> > > From: "Han Pingtian" <hanpt@linux.vnet.ibm.com>
> > > To: ltp-list@lists.sourceforge.net
> > > Sent: Tuesday, 8 July, 2014 9:23:08 AM
> > > Subject: Re: [LTP] [RFC PATCH] regression test for 64bit sendfile capped
> > > at
> > > 	2G
> > > 
> > > On Mon, Jul 07, 2014 at 08:14:39AM -0400, Jan Stancek wrote:
> > > > 
> > > > 
> > > Thanks so much. I have changed the patch according to you and
> > > Xiaoguang's suggestions. Please have a look.
> > 
> > Hi,
> > 
> > Below are some small suggestions, mostly to avoid int type related
> > warnings when compiled as 32-bit.
> > 
> > Did you also test this testcase with kernel commit 5d73320a96fcc applied?
> > I tried it with this commit applied on top of RHEL7 GA kernel, but
> > I didn't get the expected result:
> > 
> > sendfile(3, 4, [0], 4294967296)         = 2147418112
> > ...
> > sendfile(3, 4, [2147483648], 2147483648) = 2147418112
> 
> do_sendfile()
>   rw_verify_area()
>     return count > MAX_RW_COUNT ? MAX_RW_COUNT : count;
> 
> #define MAX_RW_COUNT (INT_MAX & PAGE_CACHE_MASK)
> 
> which appears to match return value I get:
>   2147418112 == 0x7FFF0000
> 
> printf("%d %d\n", sizeof(int), getpagesize());
>   4 65536
> 
> Can sendfile work with sizes > 2GB?

I think the problem addressed in commit 5d73320a96fcc was using sendfile on large files,
and not making large (count > 2GB) sendfile() calls.

Taking this into account, I can see the difference with/without commit 5d73320a96fcc.
Second case here fails on unpatched kernel with:

sendfile(3, 4, [3221225472], 1073741824) = -1 EOVERFLOW (Value too large for defined data type)


diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index 975c150..b9d49cf 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -750,6 +750,8 @@
 /sendfile/sendfile07_64
 /sendfile/sendfile08
 /sendfile/sendfile08_64
+/sendfile/sendfile09
+/sendfile/sendfile09_64
 /sendmsg/sendmsg01
 /sendmsg/sendmsg02
 /sendto/sendto01
diff --git a/testcases/kernel/syscalls/sendfile/sendfile09.c b/testcases/kernel/syscalls/sendfile/sendfile09.c
index 1bab702..c33b084 100644
--- a/testcases/kernel/syscalls/sendfile/sendfile09.c
+++ b/testcases/kernel/syscalls/sendfile/sendfile09.c
@@ -71,55 +71,51 @@ static int out_fd;
 static void cleanup(void);
 static void setup(void);

-struct test_case_t {
+#define ONE_GB (INT64_C(1) << 30)
+
+static struct test_case_t {
        char *desc;
        OFF_T offset;
+       int64_t count;
        int64_t exp_retval;
        int64_t exp_updated_offset;
 } testcases[] = {
        { "Test sendfile(2) with offset = 0",
-           0, 4294967296, 4294967296},
+           0, ONE_GB, ONE_GB, ONE_GB},
        { "Test sendfile(2) with offset in the middle of file",
-           2147483648, 2147483648, 4294967296}
+           3*ONE_GB, ONE_GB, ONE_GB, 4*ONE_GB}
 };

 int TST_TOTAL = ARRAY_SIZE(testcases);

-#ifdef UCLINUX
-static char *argv0;
-#endif
-
-void do_sendfile(OFF_T offset, int i)
+void do_sendfile(struct test_case_t *t)
 {
-       struct stat sb;
        off_t before_pos, after_pos;

        out_fd = SAFE_OPEN(cleanup, out_file, O_WRONLY);

        in_fd = SAFE_OPEN(cleanup, in_file, O_RDONLY);

-       SAFE_STAT(cleanup, in_file, &sb);
-
        before_pos = SAFE_LSEEK(cleanup, in_fd, 0, SEEK_CUR);

-       TEST(sendfile(out_fd, in_fd, &offset, sb.st_size - offset));
+       TEST(sendfile(out_fd, in_fd, &t->offset, t->count));

        if (TEST_RETURN == -1)
-               tst_brkm(TBROK | TERRNO, cleanup, "sendfile(2) failed");
+               tst_brkm(TBROK | TTERRNO, cleanup, "sendfile(2) failed");

        after_pos = SAFE_LSEEK(cleanup, in_fd, 0, SEEK_CUR);

-       if (TEST_RETURN != testcases[i].exp_retval) {
+       if (TEST_RETURN != t->exp_retval) {
                tst_resm(TFAIL, "sendfile(2) failed to return "
                         "expected value, expected: %" PRId64 ", "
-                        "got: %" PRId64, testcases[i].exp_retval,
+                        "got: %ld", t->exp_retval,
                         TEST_RETURN);
-       } else if (offset != testcases[i].exp_updated_offset) {
+       } else if (t->offset != t->exp_updated_offset) {
                tst_resm(TFAIL, "sendfile(2) failed to update "
                         "OFFSET parameter to expected value, "
                         "expected: %" PRId64 ", got: %" PRId64,
-                        testcases[i].exp_updated_offset,
-                        (int64_t) offset);
+                        t->exp_updated_offset,
+                        (int64_t) t->offset);
        } else if (before_pos != after_pos) {
                tst_resm(TFAIL, "sendfile(2) updated the file position "
                         " of in_fd unexpectedly, expected file position: %"
@@ -149,8 +145,7 @@ void setup(void)
        tst_tmpdir();

        if (!tst_fs_has_free(NULL, ".", 8, TST_GB)) {
-               cleanup();
-               tst_brkm(TCONF, NULL, "sendfile(2) on large file"
+               tst_brkm(TCONF, cleanup, "sendfile(2) on large file"
                        " needs 8G free space.");
        }

@@ -224,7 +219,7 @@ int main(int ac, char **av)
                tst_count = 0;

                for (i = 0; i < TST_TOTAL; ++i)
-                       do_sendfile(testcases[i].offset, i);
+                       do_sendfile(&testcases[i]);
        }

        cleanup();

Regards,
Jan


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2014-07-08 12:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-04  3:16 [LTP] [RFC PATCH] regression test for 64bit sendfile capped at 2G Han Pingtian
2014-07-07 12:14 ` Jan Stancek
2014-07-08  7:23   ` Han Pingtian
2014-07-08 10:36     ` Jan Stancek
2014-07-08 11:55       ` Jan Stancek
2014-07-08 12:30         ` Jan Stancek [this message]
2014-07-08 14:42           ` Han Pingtian
2014-07-14  7:40             ` Jan Stancek
2014-07-08  6:33 ` Xiaoguang Wang
2014-07-07  6:51   ` Han Pingtian
2014-07-08  7:46     ` Xiaoguang Wang
2014-07-07 11:44       ` Han Pingtian
2014-07-15 10:10   ` chrubis

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=2026740901.5816308.1404822634671.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=hanpt@linux.vnet.ibm.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.