]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_putobj.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2018 Red Hat, Inc.
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
16 #include "rgw_putobj.h"
18 namespace rgw::putobj
{
20 int ChunkProcessor::process(bufferlist
&& data
, uint64_t offset
)
22 ceph_assert(offset
>= chunk
.length());
23 uint64_t position
= offset
- chunk
.length();
25 const bool flush
= (data
.length() == 0);
27 if (chunk
.length() > 0) {
28 int r
= Pipe::process(std::move(chunk
), position
);
33 return Pipe::process({}, offset
);
35 chunk
.claim_append(data
);
37 // write each full chunk
38 while (chunk
.length() >= chunk_size
) {
40 chunk
.splice(0, chunk_size
, &bl
);
42 int r
= Pipe::process(std::move(bl
), position
);
46 position
+= chunk_size
;
52 int StripeProcessor::process(bufferlist
&& data
, uint64_t offset
)
54 ceph_assert(offset
>= bounds
.first
);
56 const bool flush
= (data
.length() == 0);
58 return Pipe::process({}, offset
- bounds
.first
);
61 auto max
= bounds
.second
- offset
;
62 while (data
.length() > max
) {
65 data
.splice(0, max
, &bl
);
67 int r
= Pipe::process(std::move(bl
), offset
- bounds
.first
);
74 // flush the current chunk
75 int r
= Pipe::process({}, offset
- bounds
.first
);
79 // generate the next stripe
81 r
= gen
->next(offset
, &stripe_size
);
85 ceph_assert(stripe_size
> 0);
87 bounds
.first
= offset
;
88 bounds
.second
= offset
+ stripe_size
;
93 if (data
.length() == 0) { // don't flush the chunk here
96 return Pipe::process(std::move(data
), offset
- bounds
.first
);
99 } // namespace rgw::putobj