uint64_t f_namemax; /* maximum filename length */
};
+/*
+ lookup object by name (POSIX style)
+*/
+int rgw_lookup(struct rgw_fs *rgw_fs,
+ struct rgw_file_handle *parent_fh, const char *path,
+ struct rgw_file_handle **fh, uint32_t flags);
+
+/*
+ lookup object by handle (NFS style)
+*/
+int rgw_lookup_handle(struct rgw_fs *rgw_fs, struct rgw_fh_hk fh_hk,
+ struct rgw_file_handle **fh, uint32_t flags);
+
+/*
+ * release file handle
+ */
+int rgw_fh_rele(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
+ uint32_t flags);
+
/*
attach rgw namespace
*/
struct rgw_file_handle *parent_fh, const char* path);
/*
- lookup a directory or file
-*/
-int rgw_lookup(struct rgw_fs *rgw_fs,
- struct rgw_file_handle *parent_fh, const char *path,
- struct rgw_file_handle **fh, uint32_t flags);
-
-/*
- * release file handle
- */
-int rgw_fh_rele(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
- uint32_t flags);
-
-/*
- read directory content
+ read directory content
*/
typedef bool (*rgw_readdir_cb)(const char *name, void *arg, uint64_t offset);
#define RGW_CLOSE_FLAG_NONE 0x0000
#define RGW_CLOSE_FLAG_RELE 0x0001
-
+
int rgw_close(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
uint32_t flags);
int rgw_read(struct rgw_fs *rgw_fs,
struct rgw_file_handle *fh, uint64_t offset,
size_t length, size_t *bytes_read, void *buffer);
-
+
/*
write data to file
*/
}
/*
- lookup a directory or file
+ lookup object by name (POSIX style)
*/
int rgw_lookup(struct rgw_fs *rgw_fs,
struct rgw_file_handle *parent_fh, const char* path,
return 0;
} /* rgw_lookup */
+/*
+ lookup object by handle (NFS style)
+*/
+int rgw_lookup_handle(struct rgw_fs *rgw_fs, struct rgw_fh_hk fh_hk,
+ struct rgw_file_handle **fh, uint32_t flags)
+{
+ RGWLibFS *fs = static_cast<RGWLibFS*>(rgw_fs->fs_private);
+
+ RGWFileHandle* rgw_fh = fs->lookup_handle(fh_hk);
+ if (! rgw_fh) {
+ /* not found */
+ return ENOENT;
+ }
+
+ struct rgw_file_handle *rfh = rgw_fh->get_fh();
+ *fh = rfh;
+
+ return 0;
+}
+
/*
* release file handle
*/
return fh;
}
+ /* find or create an RGWFileHandle */
+ RGWFileHandle* lookup_handle(struct rgw_fh_hk fh_hk) {
+
+ RGWFileHandle::FHCache::Latch lat;
+ fh_key fhk(fh_hk);
+
+ RGWFileHandle* fh =
+ fh_cache.find_latch(fhk.fh_hk.object /* partition selector*/,
+ fhk /* key */, lat /* serializer */,
+ RGWFileHandle::FHCache::FLAG_LOCK);
+ /* LATCHED */
+ if (! fh) {
+ lsubdout(get_context(), rgw, 0)
+ << __func__ << " handle lookup failed <"
+ << fhk.fh_hk.bucket << "," << fhk.fh_hk.object << ">"
+ << "(need persistent handles)"
+ << dendl;
+ goto out;
+ }
+ intrusive_ptr_add_ref(fh); /* call path/handle ref */
+ out:
+ lat.lock->unlock(); /* !LATCHED */
+ return fh;
+ }
+
+ CephContext* get_context() {
+ return static_cast<CephContext*>(get_fs()->fs_private);
+ }
+
struct rgw_fs* get_fs() { return &fs; }
RGWUserInfo* get_user() { return &user; }