reply // about memory alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for your reply.

uint32_t get_data_offset() {
return data.largest_data_off_in_tbl +
            sizeof(__u8) +      // encode struct_v
            sizeof(__u8) +      // encode compat_v
            sizeof(__u32) +     // encode len
            sizeof(__u32);      // data_bl len
}
1+1+4+4 = 10, mean that largest_data_off_in_tbl + 10

oid write(const coll_t& cid, const ghobject_t& oid, uint64_t off, uint64_t len,
>                 const bufferlist& write_data, uint32_t flags = 0) {
......
>       assert(len == write_data.length());
>       data.fadvise_flags = data.fadvise_flags | flags;
>       if (write_data.length() > data.largest_data_len) {
>          data.largest_data_len = write_data.length();
>          data.largest_data_off = off;
>          data.largest_data_off_in_data_bl = orig_len + sizeof(__u32);  // we are about to
>       }
>       data.ops++;
> }
Mean that largest_data_off_in_tbl +10 +4

using debug info , I find that encoded buffer list , has 14 bytes before data. So I think "+10 +4" for encode.

I think data.largest_data_off_in_tbl has recorded data_bl_len using " sizeof(__u32); // data_bl len " ,  
what's the diff between " data_bl len " and " orig_len + sizeof(__u32);"?

-----邮件原件-----
发件人: Gregory Farnum [mailto:gfarnum@xxxxxxxxxx] 
发送时间: 2017年11月19日 18:34
收件人: liuhao 13701
抄送: ceph-devel
主题: Re: about memory alignment

On Tue, Nov 14, 2017 at 12:12 AM Liuhao <liu.haoA@xxxxxxx> wrote:
>
> HI, developers:
>
> data.largest_data_off_in_data_bl = orig_len + sizeof(__u32);  // we 
> are about to What 's mean of sizeof(__u32)?  Why add sizeof(__u32)?


We're recording here the total size of the buffer used to transmit the data. Since the buffer includes a prefix of its own length, and that prefix is a __u32, we add that to the actual data size.
-Greg

>
>
> Detail:
> oid write(const coll_t& cid, const ghobject_t& oid, uint64_t off, uint64_t len,
>                 const bufferlist& write_data, uint32_t flags = 0) {
>       uint32_t orig_len = data_bl.length();
>       Op* _op = _get_next_op();
>       _op->op = OP_WRITE;
>       _op->cid = _get_coll_id(cid);
>       _op->oid = _get_object_id(oid);
>       _op->off = off;
>       _op->len = len;
>       ::encode(write_data, data_bl);
>
>       assert(len == write_data.length());
>       data.fadvise_flags = data.fadvise_flags | flags;
>       if (write_data.length() > data.largest_data_len) {
>          data.largest_data_len = write_data.length();
>          data.largest_data_off = off;
>          data.largest_data_off_in_data_bl = orig_len + sizeof(__u32);  // we are about to
>       }
>       data.ops++;
> }
>
> Thanks
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" 
> in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo 
> info at  http://vger.kernel.org/majordomo-info.html
��.n��������+%������w��{.n����z��u���ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux