librgw: forge Unix attrs in rgw_create

Possibly RGW vnodes should cache Unix attrs, it would reduce the
latency of (frequent) getattr calls, and eventually lines up with
more materialized Unix attributes.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
This commit is contained in:
Matt Benjamin 2015-11-12 10:32:12 -05:00
parent c480472f00
commit 5f4ef7edff

View File

@ -35,6 +35,13 @@ const string RGWFileHandle::root_name = "/";
atomic<uint32_t> RGWLibFS::fs_inst;
#define RGW_RWXMODE (S_IRWXU | S_IRWXG | S_IRWXO)
#define RGW_RWMODE (RGW_RWXMODE & \
~(S_IXUSR | S_IXGRP | S_IXOTH))
/* librgw */
extern "C" {
@ -134,8 +141,24 @@ int rgw_create(struct rgw_fs *rgw_fs,
/* mark if we created it */
if (get<1>(fhr) & RGWFileHandle::FLAG_CREATE)
if (get<1>(fhr) & RGWFileHandle::FLAG_CREATE) {
/* fill in stat data */
time_t now = time(0);
memset(st, 0, sizeof(struct stat));
st->st_dev = fs->get_inst();
st->st_ino = rgw_fh->get_fh()->fh_hk.object; // XXX
st->st_mode = RGW_RWMODE|S_IFREG;
st->st_nlink = 1;
st->st_uid = 0; // XXX
st->st_gid = 0; // XXX
st->st_size = 0;
st->st_blksize = 4096;
st->st_blocks = 0;
st->st_atim.tv_sec = now;
st->st_mtim.tv_sec = now;
st->st_ctim.tv_sec = now;
rgw_fh->open_for_create();
}
struct rgw_file_handle *rfh = rgw_fh->get_fh();
*fh = rfh;
@ -343,11 +366,6 @@ int rgw_fh_rele(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
return 0;
}
#define RGW_RWXMODE (S_IRWXU | S_IRWXG | S_IRWXO)
#define RGW_RWMODE (RGW_RWXMODE & \
~(S_IXUSR | S_IXGRP | S_IXOTH))
/*
get unix attributes for object
*/