~ubuntu-branches/ubuntu/raring/ceph/raring

« back to all changes in this revision

Viewing changes to src/rgw/rgw_cache.h

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2012-02-05 10:07:38 UTC
  • mfrom: (1.1.7) (0.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20120205100738-00s0bxx93mamy8tk
Tags: 0.41-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
  uint64_t size;
22
22
  time_t mtime;
23
23
 
 
24
  ObjectMetaInfo() : size(0), mtime(0) {}
 
25
 
24
26
  void encode(bufferlist& bl) const {
25
27
    __u8 struct_v = 1;
26
28
    ::encode(struct_v, bl);
76
78
  off_t ofs;
77
79
  string ns;
78
80
 
 
81
  RGWCacheNotifyInfo() : op(0), ofs(0) {}
 
82
 
79
83
  void encode(bufferlist& obl) const {
80
84
    __u8 struct_v = 1;
81
85
    ::encode(struct_v, obl);
173
177
  int set_attr(void *ctx, rgw_obj& obj, const char *name, bufferlist& bl);
174
178
  int put_obj_meta(void *ctx, rgw_obj& obj, uint64_t size, time_t *mtime,
175
179
                   map<std::string, bufferlist>& attrs, RGWObjCategory category, bool exclusive,
176
 
                   map<std::string, bufferlist>* rmattrs);
 
180
                   map<std::string, bufferlist>* rmattrs, const bufferlist *data);
177
181
 
178
182
  int put_obj_data(void *ctx, rgw_obj& obj, const char *data,
179
 
              off_t ofs, size_t len);
 
183
              off_t ofs, size_t len, bool exclusive);
180
184
 
181
185
  int get_obj(void *ctx, void **handle, rgw_obj& obj, char **data, off_t ofs, off_t end);
182
186
 
183
 
  int obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, map<string, bufferlist> *attrs);
 
187
  int obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, map<string, bufferlist> *attrs, bufferlist *first_chunk);
184
188
 
185
189
  int delete_obj(void *ctx, rgw_obj& obj, bool sync);
186
190
};
279
283
template <class T>
280
284
int RGWCache<T>::put_obj_meta(void *ctx, rgw_obj& obj, uint64_t size, time_t *mtime,
281
285
                              map<std::string, bufferlist>& attrs, RGWObjCategory category, bool exclusive,
282
 
                              map<std::string, bufferlist>* rmattrs)
 
286
                              map<std::string, bufferlist>* rmattrs, const bufferlist *data)
283
287
{
284
288
  rgw_bucket bucket;
285
289
  string oid;
291
295
    info.xattrs = attrs;
292
296
    info.status = 0;
293
297
    info.flags = CACHE_FLAG_XATTRS;
 
298
    if (data) {
 
299
      info.data = *data;
 
300
      info.flags |= CACHE_FLAG_DATA;
 
301
    }
294
302
  }
295
 
  int ret = T::put_obj_meta(ctx, obj, size, mtime, attrs, category, exclusive, rmattrs);
 
303
  int ret = T::put_obj_meta(ctx, obj, size, mtime, attrs, category, exclusive, rmattrs, data);
296
304
  if (cacheable) {
297
305
    string name = normal_name(bucket, oid);
298
306
    if (ret >= 0) {
310
318
 
311
319
template <class T>
312
320
int RGWCache<T>::put_obj_data(void *ctx, rgw_obj& obj, const char *data,
313
 
              off_t ofs, size_t len)
 
321
              off_t ofs, size_t len, bool exclusive)
314
322
{
315
323
  rgw_bucket bucket;
316
324
  string oid;
327
335
    info.status = 0;
328
336
    info.flags = CACHE_FLAG_DATA;
329
337
  }
330
 
  int ret = T::put_obj_data(ctx, obj, data, ofs, len);
 
338
  int ret = T::put_obj_data(ctx, obj, data, ofs, len, exclusive);
331
339
  if (cacheable) {
332
340
    string name = normal_name(bucket, oid);
333
341
    if (ret >= 0) {
344
352
}
345
353
 
346
354
template <class T>
347
 
int RGWCache<T>::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, map<string, bufferlist> *attrs)
 
355
int RGWCache<T>::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, map<string, bufferlist> *attrs, bufferlist *first_chunk)
348
356
{
349
357
  rgw_bucket bucket;
350
358
  string oid;
351
359
  normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
352
360
  if (bucket.name[0] != '.')
353
 
    return T::obj_stat(ctx, obj, psize, pmtime, attrs);
 
361
    return T::obj_stat(ctx, obj, psize, pmtime, attrs, first_chunk);
354
362
 
355
363
  string name = normal_name(bucket, oid);
356
364
 
367
375
    mtime = info.meta.mtime;
368
376
    goto done;
369
377
  }
370
 
  r = T::obj_stat(ctx, obj, &size, &mtime, &info.xattrs);
 
378
  r = T::obj_stat(ctx, obj, &size, &mtime, &info.xattrs, first_chunk);
371
379
  if (r < 0) {
372
380
    if (r == -ENOENT) {
373
381
      info.status = r;