]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: add FADVISE_NOREUSE 3477/head
authorSage Weil <sage@redhat.com>
Fri, 23 Jan 2015 17:06:32 +0000 (09:06 -0800)
committerSage Weil <sage@redhat.com>
Fri, 23 Jan 2015 17:06:32 +0000 (09:06 -0800)
We left this off because it seemed the same as DONTNEED, but there is a
subtle distinction: DONTNEED means nobody will need it (and we probably
discard our cache), while NOREUSE means this client won't need it again
(and we should try to avoid polluting the cache from this IO only).  At
least, that's the way we'r defining it.  posix_fadvise says:

       POSIX_FADV_NOREUSE
              The specified data will be accessed only once.
       POSIX_FADV_DONTNEED
              The specified data will not be accessed in the near future.

which is similar.  I think our definitions make a bit more sense for the
multi-client environment.

Signed-off-by: Sage Weil <sage@redhat.com>
src/include/rados.h
src/include/rados/librados.h
src/include/rados/librados.hpp
src/librados/librados.cc
src/osd/osd_types.cc
src/test/librados/aio.cc
src/test/librados/c_write_operations.cc
src/test/librados/io.cc
src/test/librbd/test_librbd.cc

index c760898644f64832a553af0832f85e19b778f7fe..80542ab493adcb046192071db7c0b6ef7d71d8da 100644 (file)
@@ -418,6 +418,7 @@ enum {
        CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL = 0x8, /* the op is sequential */
        CEPH_OSD_OP_FLAG_FADVISE_WILLNEED   = 0x10,/* data will be accessed in the near future */
        CEPH_OSD_OP_FLAG_FADVISE_DONTNEED   = 0x20,/* data will not be accessed in the near future */
+       CEPH_OSD_OP_FLAG_FADVISE_NOREUSE   = 0x40, /* data will be accessed only once by this client */
 };
 
 #define EOLDSNAPC    85  /* ORDERSNAP flag set; writer has old snapc*/
index 9a35307f2b33a6f0d523dec733108ba4eed61f94..7cb004a4b5d5316af531184badafdbc5b8a99f25 100644 (file)
@@ -78,6 +78,8 @@ enum {
   LIBRADOS_OP_FLAG_FADVISE_WILLNEED   = 0x10,
   // indicate read/write data will not accessed int the near future
   LIBRADOS_OP_FLAG_FADVISE_DONTNEED   = 0x20,
+  // indicate read/write data will not accessed just once by this client
+  LIBRADOS_OP_FLAG_FADVISE_NOREUSE   = 0x40,
 };
 
 #if __GNUC__ >= 4
index 7be99680207a39672ae73d09f2efb52c44772422..744a8a6227c5ff2f8dc9c68540d94a77f8d4dbb0 100644 (file)
@@ -222,6 +222,7 @@ namespace librados
     OP_FADVISE_SEQUENTIAL = LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL,
     OP_FADVISE_WILLNEED = LIBRADOS_OP_FLAG_FADVISE_WILLNEED,
     OP_FADVISE_DONTNEED = LIBRADOS_OP_FLAG_FADVISE_DONTNEED,
+    OP_FADVISE_NOREUSE = LIBRADOS_OP_FLAG_FADVISE_NOREUSE,
   };
 
   class CEPH_RADOS_API ObjectOperationCompletion {
index dfbedaa0eb9f7dea865660780f2208ea6be2777c..28f60aaefae6aa17b9b581c3e1335e92d19fa05e 100644 (file)
@@ -98,6 +98,8 @@ static void set_op_flags(::ObjectOperation *o, int flags)
     rados_flags |= CEPH_OSD_OP_FLAG_FADVISE_WILLNEED;
   if (flags & LIBRADOS_OP_FLAG_FADVISE_DONTNEED)
     rados_flags |= CEPH_OSD_OP_FLAG_FADVISE_DONTNEED;
+  if (flags & LIBRADOS_OP_FLAG_FADVISE_NOREUSE)
+    rados_flags |= CEPH_OSD_OP_FLAG_FADVISE_NOREUSE;
   o->set_last_op_flags(rados_flags);
 }
 
index 324dd45b7ad2b09a4f8f44a8acca523213958c7f..2c313cdc699cdb59546bc7720814a94ccc4518a9 100644 (file)
@@ -92,6 +92,9 @@ const char * ceph_osd_op_flag_name(unsigned flag)
     case CEPH_OSD_OP_FLAG_FADVISE_DONTNEED:
       name = "fadvise_dontneed";
       break;
+    case CEPH_OSD_OP_FLAG_FADVISE_NOREUSE:
+      name = "fadvise_noreuse";
+      break;
     default:
       name = "???";
   };
index 34f740ddb5e9a842249d8575bf527e761a635ae0..164f0f9880e33dbb1d6e22edbc34684267d2944e 100644 (file)
@@ -2624,7 +2624,7 @@ TEST(LibRadosAioEC, RoundTripWriteFullPP2)
   bl.append(buf);
 
   op.write_full(bl);
-  op.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
+  op.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_NOREUSE);
   ioctx.aio_operate("test_obj", my_completion1.get(), &op);
   {
     TestAlarm alarm;
@@ -2636,7 +2636,7 @@ TEST(LibRadosAioEC, RoundTripWriteFullPP2)
   bl.clear();
   ObjectReadOperation op1;
   op1.read(0, sizeof(buf), &bl, NULL);
-  op1.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_DONTNEED|LIBRADOS_OP_FLAG_FADVISE_RANDOM);
+  op1.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_NOREUSE|LIBRADOS_OP_FLAG_FADVISE_RANDOM);
   ioctx.aio_operate("test_obj", my_completion2.get(), &op1, 0);
   {
     TestAlarm alarm;
index ff08bda66896f735c8580224d579a98ecaa236fb..d4ef4785063a9411d29925f92f4393bc55a8577a 100644 (file)
@@ -100,7 +100,7 @@ TEST(LibRadosCWriteOps, Write) {
   op = rados_create_write_op();
   ASSERT_TRUE(op);
   rados_write_op_write_full(op, "ceph", 4);
-  rados_write_op_set_flags(op, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
+  rados_write_op_set_flags(op, LIBRADOS_OP_FLAG_FADVISE_NOREUSE);
   ASSERT_EQ(0, rados_write_op_operate(op, ioctx, "test", NULL, 0));
   ASSERT_EQ(4, rados_read(ioctx, "test", hi, 4, 0));
   rados_release_write_op(op);
index 4a709b797ef740be0e213bcba47503ce99cac3e7..7bb9b9190ee3e39122f2911832c92a08a3ef5754 100644 (file)
@@ -256,7 +256,7 @@ TEST_F(LibRadosIoPP, RoundTripPP2)
 
   ObjectReadOperation read;
   read.read(0, bl.length(), NULL, NULL);
-  read.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_DONTNEED|LIBRADOS_OP_FLAG_FADVISE_RANDOM);
+  read.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_NOREUSE|LIBRADOS_OP_FLAG_FADVISE_RANDOM);
   ASSERT_EQ(0, ioctx.operate("foo", &read, &bl));
   ASSERT_EQ(0, memcmp(bl.c_str(), "ceph", 4));
 }
@@ -327,7 +327,7 @@ TEST_F(LibRadosIoPP, WriteFullRoundTripPP2)
   bl.append("ceph");
   ObjectWriteOperation write;
   write.write_full(bl);
-  write.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
+  write.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_NOREUSE);
   ASSERT_EQ(0, ioctx.operate("foo", &write));
 
   ObjectReadOperation read;
index 71648726bd5a6bc087fc13aa6358f6cda934110c..bca89a2498d74325020a225a2a545ee019503518 100644 (file)
@@ -843,7 +843,7 @@ TEST_F(TestLibRBD, TestIOWithIOHint)
 
   for (i = 0; i < 5; ++i)
     ASSERT_PASSED(write_test_data, image, test_data, TEST_IO_SIZE * i,
-                 TEST_IO_SIZE, LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
+                 TEST_IO_SIZE, LIBRADOS_OP_FLAG_FADVISE_NOREUSE);
 
   for (i = 5; i < 10; ++i)
     ASSERT_PASSED(aio_write_test_data, image, test_data, TEST_IO_SIZE * i,
@@ -879,7 +879,7 @@ TEST_F(TestLibRBD, TestIOWithIOHint)
   ASSERT_EQ(-EINVAL, rbd_read(image, info.size, 1, test_data));
   // reading through end returns amount up to end
   ASSERT_EQ(10, rbd_read2(image, info.size - 10, 100, test_data,
-                         LIBRADOS_OP_FLAG_FADVISE_DONTNEED));
+                         LIBRADOS_OP_FLAG_FADVISE_NOREUSE));
   // writing through end returns amount up to end
   ASSERT_EQ(10, rbd_write2(image, info.size - 10, 100, test_data,
                            LIBRADOS_OP_FLAG_FADVISE_DONTNEED));
@@ -1099,7 +1099,7 @@ TEST_F(TestLibRBD, TestIOPPWithIOHint)
 
     for (i = 0; i < 5; ++i)
       ASSERT_PASSED(write_test_data, image, test_data, strlen(test_data) * i,
-                   LIBRADOS_OP_FLAG_FADVISE_DONTNEED);
+                   LIBRADOS_OP_FLAG_FADVISE_NOREUSE);
 
     for (i = 5; i < 10; ++i)
       ASSERT_PASSED(aio_write_test_data, image, test_data, strlen(test_data) * i,