]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
seastore : add atomic write unit interface
authorJinyong Ha <jy200.ha@samsung.com>
Thu, 14 Oct 2021 02:27:33 +0000 (11:27 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Fri, 12 Nov 2021 04:29:05 +0000 (13:29 +0900)
Atomic Write Unit from SSD is maximum write IO size whose atomicity is
guaranteed by SSD. Write IO smaller than this value does not require
syncronization such as fsync(). Even after power state is changed, the
atomicity is guaranteed.

Signed-off-by: Jinyong Ha <jy200.ha@samsung.com>
src/crimson/os/seastore/random_block_manager/nvmedevice.cc
src/crimson/os/seastore/random_block_manager/nvmedevice.h

index 1949aca724885707b8b13162aefb63474e10d9c2..84b1353d4b9a7060976efd1af5c8185b23cb65dc 100644 (file)
@@ -36,11 +36,13 @@ open_ertr::future<> PosixNVMeDevice::open(
           if (support_multistream) {
             stream_id_count = WRITE_LIFE_MAX;
           }
+          awupf = id_controller_data.awupf + 1;
           return identify_namespace().safe_then([this, in_path, mode] (
             auto id_namespace_data) {
             // LBA format provides LBA size which is power of 2. LBA is the
             // minimum size of read and write.
             block_size = (1 << id_namespace_data.lbaf0.lbads);
+            atomic_write_unit = awupf * block_size;
             data_protection_type = id_namespace_data.dps.protection_type;
             data_protection_enabled = (data_protection_type > 0);
             if (id_namespace_data.nsfeat.opterf == 1){
index 2b3e99f53dac4f2c8afa5a02a481265f569210b4..f54eb10db7e61fb2082b6f119495553110c8d4e8 100644 (file)
@@ -95,8 +95,10 @@ struct oacs_t {
 struct nvme_identify_controller_data_t {
   union {
     struct {
-      uint8_t unused[256];
-      oacs_t oacs;
+      uint8_t unused[256];  // [255:0]
+      oacs_t oacs;          // [257:256]
+      uint8_t unused2[270]; // [527:258]
+      uint16_t awupf;       // [529:528]
     };
     uint8_t raw[4096];
   };
@@ -236,6 +238,7 @@ protected:
 
   uint64_t write_granularity = 4096;
   uint64_t write_alignment = 4096;
+  uint32_t atomic_write_unit = 4096;
 
   bool data_protection_enabled = false;
 
@@ -260,6 +263,9 @@ public:
    * size for write in byte. Caller should request every write IO sized multiple
    * times of PWG and aligned starting address by PWA. Available only if NVMe
    * Device supports NVMe protocol 1.4 or later versions.
+   * atomic_write_unit : The maximum size of write whose atomicity is guranteed
+   * by SSD even on power failure. The write equal to or smaller than 
+   * atomic_write_unit does not require fsync().
    */
   uint64_t get_size() const { return size; }
   uint64_t get_block_size() const { return block_size; }
@@ -267,6 +273,8 @@ public:
   uint64_t get_preffered_write_granularity() const { return write_granularity; }
   uint64_t get_preffered_write_alignment() const { return write_alignment; }
 
+  uint64_t get_atomic_write_unit() const { return atomic_write_unit; }
+
   virtual read_ertr::future<> read(
     uint64_t offset,
     bufferptr &bptr) = 0;
@@ -395,6 +403,7 @@ private:
   std::vector<seastar::file> io_device;
   uint32_t stream_index_to_open = WRITE_LIFE_NOT_SET;
   uint32_t stream_id_count = 1; // stream is disabled, defaultly.
+  uint32_t awupf = 0;
 };