From: Sage Weil Date: Thu, 29 Jan 2015 21:00:15 +0000 (-0800) Subject: librados: rename NOREUSE to NOCACHE X-Git-Tag: v0.93~159^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F3543%2Fhead;p=ceph.git librados: rename NOREUSE to NOCACHE 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 --- diff --git a/src/include/rados.h b/src/include/rados.h index 80542ab493ad..7ebd52a5fa8e 100644 --- a/src/include/rados.h +++ b/src/include/rados.h @@ -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*/ diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index 7cb004a4b5d5..67113dd34718 100644 --- a/src/include/rados/librados.h +++ b/src/include/rados/librados.h @@ -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 diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 9efd2b43d697..77e334b6eca5 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -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 { diff --git a/src/librados/librados.cc b/src/librados/librados.cc index decf175555ff..bdcc4c373693 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -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); } diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 2c313cdc699c..7a2a35f62d61 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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 = "???"; diff --git a/src/test/librados/aio.cc b/src/test/librados/aio.cc index 164f0f9880e3..37b3094b04f5 100644 --- a/src/test/librados/aio.cc +++ b/src/test/librados/aio.cc @@ -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; diff --git a/src/test/librados/c_write_operations.cc b/src/test/librados/c_write_operations.cc index d4ef4785063a..7e1dc73df764 100644 --- a/src/test/librados/c_write_operations.cc +++ b/src/test/librados/c_write_operations.cc @@ -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); diff --git a/src/test/librados/io.cc b/src/test/librados/io.cc index 7bb9b9190ee3..6f391df7353b 100644 --- a/src/test/librados/io.cc +++ b/src/test/librados/io.cc @@ -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; diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index 24a5133f8cb7..39014f06aa53 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -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,