this is the simplest consistent model for an open-write-close
transaction (and it reads stable)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
struct rgw_file_handle *fh, uint32_t flags)
{
RGWFileHandle* rgw_fh = get_rgwfh(fh);
- rgw_fh->open(/* XXX */);
- return 0;
+ /* XXX
+ * need to track specific opens--at least read opens and
+ * a write open; we need to know when a write open is returned,
+ * that closes a write transaction
+ *
+ * for now, we will support single-open only, it's preferable to
+ * anything we can otherwise do without access to the NFS state
+ */
+
+ // convert flags
+ uint32_t oflags = 0;
+ return rgw_fh->open(oflags);
}
/*
/* const */ std::string name; /* XXX file or bucket name */
/* const */ fh_key fhk;
+ using lock_guard = std::lock_guard<std::mutex>;
+ using unique_lock = std::unique_lock<std::mutex>;
+
struct state {
uint64_t dev;
size_t size;
bool creating() const { return flags & FLAG_CREATE; }
bool pseudo() const { return flags & FLAG_PSEUDO; }
- void open() {
- flags |= FLAG_OPEN;
+ uint32_t open(uint32_t gsh_flags) {
+ lock_guard guard(mtx);
+ if (! (flags & FLAG_OPEN)) {
+ flags |= FLAG_OPEN;
+ return 0;
+ }
+ return EPERM;
}
void close() {
+ lock_guard guard(mtx);
flags &= ~FLAG_OPEN;
}
void open_for_create() {
+ lock_guard guard(mtx);
flags |= FLAG_CREATE;
}