]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: rename NOREUSE to NOCACHE 3543/head
authorSage Weil <sage@redhat.com>
Thu, 29 Jan 2015 21:00:15 +0000 (13:00 -0800)
committerSage Weil <sage@redhat.com>
Thu, 29 Jan 2015 21:00:15 +0000 (13:00 -0800)
As far as I can tell, the posix_fadvise() distinction between WONTNEED and
NOREUSE is subtle: one says I won't access the data, and the other says
I will access it one more time and then not access it.  That is, the
distinction is about time.  This thread seems to confirm this
interpretation:

 https://lkml.org/lkml/2011/6/27/44

Since we are attaching hints to the IO operations themselves, this
distinction doesn't make much sense for us.  (Backends should be careful
about which hint they use; or rather, they should use WONTNEED *after*
doing the IO since NOREUSE is presenting a no-op in Linux.)

However, we want to make a totally different distinction:

 WONTNEED - nobody will access this -> drop it from the cache
 NOCACHE  - *i* won't access this again -> don't let me affect your caching
            decisions or the working set you're maintaining for other
            clients.

The NOCACHE name is made-up and distinct from NOREUSE only so that it is
different from POSIX and doesn't introduce confusion for people familiar
with the POSIX meaning.  Perhaps a more accurate name would be IWONTNEED
but that is only one character apart and too error-prone IMO.

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 80542ab493adcb046192071db7c0b6ef7d71d8da..7ebd52a5fa8e30a0efcaf3289cd52d48f18814c2 100644 (file)
@@ -418,7 +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 */
+       CEPH_OSD_OP_FLAG_FADVISE_NOCACHE   = 0x40, /* data will be accessed only once by this client */
 };
 
 #define EOLDSNAPC    85  /* ORDERSNAP flag set; writer has old snapc*/
index 7cb004a4b5d5316af531184badafdbc5b8a99f25..67113dd3471813fac86aa9a380a581f3bbb6e576 100644 (file)
@@ -74,12 +74,12 @@ enum {
   LIBRADOS_OP_FLAG_FADVISE_RANDOM     = 0x4,
   // indicate read/write op sequential
   LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL = 0x8,
-  // indicate read/write data will be accessed in the near future
+  // indicate read/write data will be accessed in the near future (by someone)
   LIBRADOS_OP_FLAG_FADVISE_WILLNEED   = 0x10,
-  // indicate read/write data will not accessed int the near future
+  // indicate read/write data will not accessed in the near future (by anyone)
   LIBRADOS_OP_FLAG_FADVISE_DONTNEED   = 0x20,
-  // indicate read/write data will not accessed just once by this client
-  LIBRADOS_OP_FLAG_FADVISE_NOREUSE   = 0x40,
+  // indicate read/write data will not accessed again (by *this* client)
+  LIBRADOS_OP_FLAG_FADVISE_NOCACHE    = 0x40,
 };
 
 #if __GNUC__ >= 4
index 9efd2b43d6971d9bab7a66a91865fa73427bbad1..77e334b6eca577b107f95eb39b83e480ca700114 100644 (file)
@@ -222,7 +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,
+    OP_FADVISE_NOCACHE = LIBRADOS_OP_FLAG_FADVISE_NOCACHE,
   };
 
   class CEPH_RADOS_API ObjectOperationCompletion {
index decf175555ff53bdad5009e1134af3db9199f35b..bdcc4c3736938804a2f65c56c6e53c82297e8bb6 100644 (file)
@@ -98,8 +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;
+  if (flags & LIBRADOS_OP_FLAG_FADVISE_NOCACHE)
+    rados_flags |= CEPH_OSD_OP_FLAG_FADVISE_NOCACHE;
   o->set_last_op_flags(rados_flags);
 }
 
index 2c313cdc699cdb59546bc7720814a94ccc4518a9..7a2a35f62d61b7aeafb2feffd4b8f17215a710f0 100644 (file)
@@ -92,8 +92,8 @@ 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";
+    case CEPH_OSD_OP_FLAG_FADVISE_NOCACHE:
+      name = "fadvise_nocache";
       break;
     default:
       name = "???";
index 164f0f9880e33dbb1d6e22edbc34684267d2944e..37b3094b04f56f26778df90bb5374528e4560c54 100644 (file)
@@ -2624,7 +2624,7 @@ TEST(LibRadosAioEC, RoundTripWriteFullPP2)
   bl.append(buf);
 
   op.write_full(bl);
-  op.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_NOREUSE);
+  op.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
   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_NOREUSE|LIBRADOS_OP_FLAG_FADVISE_RANDOM);
+  op1.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_NOCACHE|LIBRADOS_OP_FLAG_FADVISE_RANDOM);
   ioctx.aio_operate("test_obj", my_completion2.get(), &op1, 0);
   {
     TestAlarm alarm;
index d4ef4785063a9411d29925f92f4393bc55a8577a..7e1dc73df764eb49855fd462a462bae75e911b24 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_NOREUSE);
+  rados_write_op_set_flags(op, LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
   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 7bb9b9190ee3e39122f2911832c92a08a3ef5754..6f391df7353bd7b751de7b1a7eb294535066ad07 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_NOREUSE|LIBRADOS_OP_FLAG_FADVISE_RANDOM);
+  read.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_NOCACHE|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_NOREUSE);
+  write.set_op_flags2(LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
   ASSERT_EQ(0, ioctx.operate("foo", &write));
 
   ObjectReadOperation read;
index 24a5133f8cb7ee01542e75d40a7a217459c59ebe..39014f06aa537c168bacf56701b17125696a48a0 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_NOREUSE);
+                 TEST_IO_SIZE, LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
 
   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_NOREUSE));
+                         LIBRADOS_OP_FLAG_FADVISE_NOCACHE));
   // 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_NOREUSE);
+                   LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
 
     for (i = 5; i < 10; ++i)
       ASSERT_PASSED(aio_write_test_data, image, test_data, strlen(test_data) * i,