X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fosdc%2FStriper.h;fp=src%2Fceph%2Fsrc%2Fosdc%2FStriper.h;h=6d110e9502fcf836c295ef12786b8a540b817fb3;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/osdc/Striper.h b/src/ceph/src/osdc/Striper.h new file mode 100644 index 0000000..6d110e9 --- /dev/null +++ b/src/ceph/src/osdc/Striper.h @@ -0,0 +1,113 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2006 Sage Weil + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_STRIPER_H +#define CEPH_STRIPER_H + +#include "include/types.h" +#include "osd/osd_types.h" + +class CephContext; + +//namespace ceph { + + class Striper { + public: + /* + * map (ino, layout, offset, len) to a (list of) ObjectExtents (byte + * ranges in objects on (primary) osds) + */ + static void file_to_extents(CephContext *cct, const char *object_format, + const file_layout_t *layout, + uint64_t offset, uint64_t len, + uint64_t trunc_size, + map >& extents, + uint64_t buffer_offset=0); + + static void file_to_extents(CephContext *cct, const char *object_format, + const file_layout_t *layout, + uint64_t offset, uint64_t len, + uint64_t trunc_size, + vector& extents, + uint64_t buffer_offset=0); + + static void file_to_extents(CephContext *cct, inodeno_t ino, + const file_layout_t *layout, + uint64_t offset, uint64_t len, + uint64_t trunc_size, + vector& extents) { + // generate prefix/format + char buf[32]; + snprintf(buf, sizeof(buf), "%llx.%%08llx", (long long unsigned)ino); + + file_to_extents(cct, buf, layout, offset, len, trunc_size, extents); + } + + static void assimilate_extents( + map >& object_extents, + vector& extents); + + /** + * reverse map an object extent to file extents + */ + static void extent_to_file(CephContext *cct, file_layout_t *layout, + uint64_t objectno, uint64_t off, uint64_t len, + vector >& extents); + + static uint64_t object_truncate_size( + CephContext *cct, const file_layout_t *layout, + uint64_t objectno, uint64_t trunc_size); + + static uint64_t get_num_objects(const file_layout_t& layout, + uint64_t size); + /* + * helper to assemble a striped result + */ + class StripedReadResult { + // offset -> (data, intended length) + map > partial; + uint64_t total_intended_len = 0; //sum of partial.second.second + + public: + void add_partial_result( + CephContext *cct, bufferlist& bl, + const vector >& buffer_extents); + /** + * add sparse read into results + * + * @param bl buffer + * @param bl_map map of which logical source extents this covers + * @param bl_off logical buffer offset (e.g., first bl_map key + * if the buffer is not sparse) + * @param buffer_extents output buffer extents the data maps to + */ + void add_partial_sparse_result( + CephContext *cct, bufferlist& bl, + const map& bl_map, uint64_t bl_off, + const vector >& buffer_extents); + + void assemble_result(CephContext *cct, bufferlist& bl, bool zero_tail); + + /** + * @buffer copy read data into buffer + * @len the length of buffer + */ + void assemble_result(CephContext *cct, char *buffer, size_t len); + }; + + }; + +//}; + +#endif