mirror of
https://github.com/ceph/ceph
synced 2024-12-15 07:56:12 +00:00
Read cap is being passed through client
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1121 29311d96-e01e-0410-9327-a35deaab8ce9
This commit is contained in:
parent
8dae85df5b
commit
432611ef46
@ -2641,6 +2641,7 @@ int Client::read(fh_t fh, char *buf, off_t size, off_t offset,
|
||||
// grab security cap for file (mode should always be correct)
|
||||
// add that assertion
|
||||
ExtCap *read_ext_cap = in->get_ext_cap(uid);
|
||||
assert(read_ext_cap);
|
||||
|
||||
// do we have read file cap?
|
||||
while (!lazy && (in->file_caps() & CAP_FILE_RD) == 0) {
|
||||
@ -2686,14 +2687,14 @@ int Client::read(fh_t fh, char *buf, off_t size, off_t offset,
|
||||
|
||||
if (g_conf.client_oc) {
|
||||
// object cache ON
|
||||
rvalue = r = in->fc.read(offset, size, blist, client_lock); // may block.
|
||||
rvalue = r = in->fc.read(offset, size, blist, client_lock, read_ext_cap); // may block.
|
||||
} else {
|
||||
// object cache OFF -- legacy inconsistent way.
|
||||
Cond cond;
|
||||
bool done = false;
|
||||
C_Cond *onfinish = new C_Cond(&cond, &done, &rvalue);
|
||||
|
||||
r = filer->read(in->inode, offset, size, &blist, onfinish);
|
||||
r = filer->read(in->inode, offset, size, &blist, onfinish, read_ext_cap);
|
||||
|
||||
assert(r >= 0);
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include "msg/Messenger.h"
|
||||
|
||||
#include "crypto/ExtCap.h"
|
||||
|
||||
#undef dout
|
||||
#define dout(x) if (x <= g_conf.debug_client) cout << g_clock.now() << " " << oc->objecter->messenger->get_myaddr() << ".filecache "
|
||||
#define derr(x) if (x <= g_conf.debug_client) cout << g_clock.now() << " " << oc->objecter->messenger->get_myaddr() << ".filecache "
|
||||
@ -96,7 +98,7 @@ void FileCache::check_caps()
|
||||
|
||||
// read/write
|
||||
|
||||
int FileCache::read(off_t offset, size_t size, bufferlist& blist, Mutex& client_lock)
|
||||
int FileCache::read(off_t offset, size_t size, bufferlist& blist, Mutex& client_lock, ExtCap* read_ext_cap)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
@ -110,7 +112,7 @@ int FileCache::read(off_t offset, size_t size, bufferlist& blist, Mutex& client_
|
||||
int rvalue = 0;
|
||||
C_Cond *onfinish = new C_Cond(&cond, &done, &rvalue);
|
||||
|
||||
r = oc->file_read(inode, offset, size, &blist, onfinish);
|
||||
r = oc->file_read(inode, offset, size, &blist, onfinish, read_ext_cap);
|
||||
|
||||
if (r == 0) {
|
||||
// block
|
||||
@ -121,8 +123,8 @@ int FileCache::read(off_t offset, size_t size, bufferlist& blist, Mutex& client_
|
||||
// it was cached.
|
||||
delete onfinish;
|
||||
}
|
||||
} else {
|
||||
r = oc->file_atomic_sync_read(inode, offset, size, &blist, client_lock);
|
||||
} else { // cache is on but I can't rdcache
|
||||
r = oc->file_atomic_sync_read(inode, offset, size, &blist, client_lock, read_ext_cap);
|
||||
}
|
||||
|
||||
// dec reading counter
|
||||
|
@ -58,7 +58,8 @@ class FileCache {
|
||||
void set_caps(int caps, Context *onimplement=0);
|
||||
void check_caps();
|
||||
|
||||
int read(off_t offset, size_t size, bufferlist& blist, Mutex& client_lock); // may block.
|
||||
int read(off_t offset, size_t size, bufferlist& blist, Mutex& client_lock,
|
||||
ExtCap *read_ext_cap=0); // may block.
|
||||
void write(off_t offset, size_t size, bufferlist& blist, Mutex& client_lock); // may block.
|
||||
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
|
||||
cap_data_t data;
|
||||
byte sigArray[ESIGNSIGSIZE];
|
||||
SigBuf signature;
|
||||
//SigBuf signature;
|
||||
|
||||
public:
|
||||
friend class Client;
|
||||
@ -106,6 +106,7 @@ public:
|
||||
void sign_extcap(esignPriv privKey) {
|
||||
byte capArray[sizeof(data)];
|
||||
memcpy(capArray, &data, sizeof(data));
|
||||
SigBuf signature;
|
||||
signature = esignSig(capArray, sizeof(data), privKey);
|
||||
// store the signature into permanent buffer
|
||||
memcpy(sigArray, signature.data(), signature.size());
|
||||
@ -129,7 +130,7 @@ public:
|
||||
//memset(hexArray, 0x00, sizeof(hexArray));
|
||||
//toHex(sigArray, hexArray, sizeof(sigArray), sizeof(sigArray));
|
||||
//cout << "Verified signature hex: " << endl << string((const char*)hexArray,sizeof(hexArray)) << endl;
|
||||
|
||||
SigBuf signature;
|
||||
signature.Assign(sigArray, sizeof(sigArray));
|
||||
|
||||
return esignVer(capArray, sizeof(data), signature, pubKey);
|
||||
|
@ -17,6 +17,10 @@
|
||||
|
||||
#include "msg/Message.h"
|
||||
|
||||
#include "crypto/CryptoLib.h"
|
||||
#include "crypto/ExtCap.h"
|
||||
using namespace CryptoLib;
|
||||
|
||||
/*
|
||||
* OSD op
|
||||
*
|
||||
@ -107,6 +111,9 @@ private:
|
||||
bufferlist data;
|
||||
map<string,bufferptr> attrset;
|
||||
|
||||
// security capability
|
||||
ExtCap ext_cap;
|
||||
|
||||
friend class MOSDOpReply;
|
||||
|
||||
public:
|
||||
@ -144,6 +151,9 @@ private:
|
||||
const bool wants_ack() { return st.want_ack; }
|
||||
const bool wants_commit() { return st.want_commit; }
|
||||
|
||||
ExtCap* get_capability() { return &ext_cap; }
|
||||
|
||||
void set_capability(ExtCap *cap) { ext_cap = (*cap); }
|
||||
|
||||
void set_data(bufferlist &d) {
|
||||
data.claim(d);
|
||||
@ -194,11 +204,13 @@ private:
|
||||
off += sizeof(st);
|
||||
::_decode(attrset, payload, off);
|
||||
::_decode(data, payload, off);
|
||||
ext_cap._decode(payload, off);
|
||||
}
|
||||
virtual void encode_payload() {
|
||||
payload.append((char*)&st, sizeof(st));
|
||||
::_encode(attrset, payload);
|
||||
::_encode(data, payload);
|
||||
ext_cap._encode(payload);
|
||||
}
|
||||
|
||||
virtual char *get_type_name() { return "oop"; }
|
||||
|
@ -84,8 +84,14 @@ class Filer {
|
||||
off_t offset,
|
||||
size_t len,
|
||||
bufferlist *bl, // ptr to data
|
||||
Context *onfinish) {
|
||||
Objecter::OSDRead *rd = new Objecter::OSDRead(bl);
|
||||
Context *onfinish, ExtCap* read_cap=0) {
|
||||
// we should always pass a read_cap...this is just
|
||||
// to support legacy stuff
|
||||
Objecter::OSDRead *rd;
|
||||
if (!read_cap)
|
||||
rd = new Objecter::OSDRead(bl);
|
||||
else
|
||||
rd = new Objecter::OSDRead(bl, read_cap);
|
||||
file_to_extents(inode, offset, len, rd->extents);
|
||||
return objecter->readx(rd, onfinish) > 0 ? 0:-1;
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(Objecter::OSDWrite *wr
|
||||
|
||||
/* private */
|
||||
|
||||
void ObjectCacher::bh_read(BufferHead *bh)
|
||||
void ObjectCacher::bh_read(BufferHead *bh, ExtCap *read_ext_cap)
|
||||
{
|
||||
dout(7) << "bh_read on " << *bh << endl;
|
||||
|
||||
@ -387,7 +387,7 @@ void ObjectCacher::bh_read(BufferHead *bh)
|
||||
|
||||
// go
|
||||
objecter->read(bh->ob->get_oid(), bh->start(), bh->length(), &onfinish->bl,
|
||||
onfinish);
|
||||
onfinish, read_ext_cap);
|
||||
}
|
||||
|
||||
void ObjectCacher::bh_read_finish(object_t oid, off_t start, size_t length, bufferlist &bl)
|
||||
@ -695,6 +695,8 @@ int ObjectCacher::readx(Objecter::OSDRead *rd, inodeno_t ino, Context *onfinish)
|
||||
list<BufferHead*> hit_ls;
|
||||
map<size_t, bufferlist> stripe_map; // final buffer offset -> substring
|
||||
|
||||
// should assert we have a cap
|
||||
|
||||
for (list<ObjectExtent>::iterator ex_it = rd->extents.begin();
|
||||
ex_it != rd->extents.end();
|
||||
ex_it++) {
|
||||
@ -712,7 +714,7 @@ int ObjectCacher::readx(Objecter::OSDRead *rd, inodeno_t ino, Context *onfinish)
|
||||
for (map<off_t, BufferHead*>::iterator bh_it = missing.begin();
|
||||
bh_it != missing.end();
|
||||
bh_it++) {
|
||||
bh_read(bh_it->second);
|
||||
bh_read(bh_it->second, rd->ext_cap);
|
||||
if (success) {
|
||||
dout(10) << "readx missed, waiting on " << *bh_it->second
|
||||
<< " off " << bh_it->first << endl;
|
||||
|
@ -1,3 +1,15 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
|
||||
*
|
||||
* 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 __OBJECTCACHER_H_
|
||||
#define __OBJECTCACHER_H_
|
||||
|
||||
@ -331,7 +343,7 @@ class ObjectCacher {
|
||||
}
|
||||
|
||||
// io
|
||||
void bh_read(BufferHead *bh);
|
||||
void bh_read(BufferHead *bh, ExtCap* read_ext_cap=0);
|
||||
void bh_write(BufferHead *bh);
|
||||
|
||||
void trim(off_t max=-1);
|
||||
@ -469,8 +481,12 @@ class ObjectCacher {
|
||||
int file_read(inode_t& inode,
|
||||
off_t offset, size_t len,
|
||||
bufferlist *bl,
|
||||
Context *onfinish) {
|
||||
Objecter::OSDRead *rd = new Objecter::OSDRead(bl);
|
||||
Context *onfinish, ExtCap *read_ext_cap) {
|
||||
Objecter::OSDRead *rd;
|
||||
if (!read_ext_cap) // we should always have a read_cap
|
||||
rd = new Objecter::OSDRead(bl);
|
||||
else
|
||||
rd = new Objecter::OSDRead(bl, read_ext_cap);
|
||||
filer.file_to_extents(inode, offset, len, rd->extents);
|
||||
return readx(rd, inode.ino, onfinish);
|
||||
}
|
||||
@ -491,8 +507,12 @@ class ObjectCacher {
|
||||
int file_atomic_sync_read(inode_t& inode,
|
||||
off_t offset, size_t len,
|
||||
bufferlist *bl,
|
||||
Mutex &lock) {
|
||||
Objecter::OSDRead *rd = new Objecter::OSDRead(bl);
|
||||
Mutex &lock, ExtCap *read_ext_cap=0) {
|
||||
Objecter::OSDRead *rd;
|
||||
if (!read_ext_cap)
|
||||
rd = new Objecter::OSDRead(bl);
|
||||
else
|
||||
rd = new Objecter::OSDRead(bl, read_ext_cap);
|
||||
filer.file_to_extents(inode, offset, len, rd->extents);
|
||||
return atomic_sync_readx(rd, inode.ino, lock);
|
||||
}
|
||||
|
@ -354,10 +354,14 @@ void Objecter::handle_osd_stat_reply(MOSDOpReply *m)
|
||||
|
||||
|
||||
tid_t Objecter::read(object_t oid, off_t off, size_t len, bufferlist *bl,
|
||||
Context *onfinish,
|
||||
Context *onfinish, ExtCap* read_ext_cap,
|
||||
objectrev_t rev)
|
||||
{
|
||||
OSDRead *rd = new OSDRead(bl);
|
||||
OSDRead *rd;
|
||||
if (read_ext_cap) // there should always be a cap
|
||||
rd = new OSDRead(bl, read_ext_cap);
|
||||
else
|
||||
rd = new OSDRead(bl);
|
||||
rd->extents.push_back(ObjectExtent(oid, off, len));
|
||||
rd->extents.front().pgid = osdmap->object_to_pg( oid, g_OSD_FileLayout );
|
||||
rd->extents.front().rev = rev;
|
||||
@ -391,6 +395,8 @@ tid_t Objecter::readx_submit(OSDRead *rd, ObjectExtent &ex)
|
||||
OSD_OP_READ);
|
||||
m->set_length(ex.length);
|
||||
m->set_offset(ex.start);
|
||||
if (rd->ext_cap)
|
||||
m->set_capability(rd->ext_cap);
|
||||
dout(10) << "readx_submit " << rd << " tid " << last_tid
|
||||
<< " oid " << ex.oid << " " << ex.start << "~" << ex.length
|
||||
<< " (" << ex.buffer_extents.size() << " buffer fragments)"
|
||||
|
@ -1,3 +1,15 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
|
||||
*
|
||||
* 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 __OBJECTER_H
|
||||
#define __OBJECTER_H
|
||||
|
||||
@ -43,12 +55,16 @@ class Objecter {
|
||||
public:
|
||||
bufferlist *bl;
|
||||
Context *onfinish;
|
||||
ExtCap *ext_cap;
|
||||
map<tid_t, ObjectExtent> ops;
|
||||
map<object_t, bufferlist*> read_data; // bits of data as they come back
|
||||
|
||||
OSDRead(bufferlist *b) : bl(b), onfinish(0) {
|
||||
bl->clear();
|
||||
}
|
||||
OSDRead(bufferlist *b, ExtCap *cap) : bl(b), onfinish(0), ext_cap(cap) {
|
||||
bl->clear();
|
||||
}
|
||||
};
|
||||
|
||||
class OSDStat : public OSDOp {
|
||||
@ -170,7 +186,7 @@ class Objecter {
|
||||
|
||||
// even lazier
|
||||
tid_t read(object_t oid, off_t off, size_t len, bufferlist *bl,
|
||||
Context *onfinish,
|
||||
Context *onfinish, ExtCap* read_ext_cap=0,
|
||||
objectrev_t rev=0);
|
||||
tid_t write(object_t oid, off_t off, size_t len, bufferlist &bl,
|
||||
Context *onack, Context *oncommit,
|
||||
|
Loading…
Reference in New Issue
Block a user