Skip to content

Commit

Permalink
XrdCeph: Implemented Ftruncate in the CephOssFile plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Ponce authored and ljanyst committed Feb 23, 2015
1 parent 285a56a commit 7f0ef2d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/XrdCeph/CephOssFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ ssize_t CephOssFile::Write(const void *buff, off_t offset, size_t blen) {
int CephOssFile::Fsync() {
return ceph_posix_fsync(m_fd);
}

int CephOssFile::Ftruncate(unsigned long long len) {
return ceph_posix_ftruncate(m_fd, len);
}
3 changes: 2 additions & 1 deletion src/XrdCeph/CephOssFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public:
virtual int Fstat(struct stat *buff);
virtual ssize_t Write(const void *buff, off_t offset, size_t blen);
virtual int Fsync(void);

virtual int Ftruncate(unsigned long long);

private:

int m_fd;
Expand Down
23 changes: 19 additions & 4 deletions src/XrdCeph/ceph_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,17 +632,32 @@ int ceph_posix_statfs(long long *totalSpace, long long *freeSpace) {
return rc;
}

int ceph_posix_truncate(XrdOucEnv* env, const char *pathname, unsigned long long size) {
logwrapper((char*)"ceph_posix_truncate : %s\n", pathname);
// minimal stat : only size and times are filled
CephFile file = getCephFile(pathname, env);
static int ceph_posix_internal_truncate(const CephFile &file, unsigned long long size) {
libradosstriper::RadosStriper *striper = getRadosStriper(file);
if (0 == striper) {
return -EINVAL;
}
return striper->trunc(file.name, size);
}

int ceph_posix_ftruncate(int fd, unsigned long long size) {
std::map<unsigned int, CephFileRef>::iterator it = g_fds.find(fd);
if (it != g_fds.end()) {
CephFileRef &fr = it->second;
logwrapper((char*)"ceph_posix_ftruncate: fd %d, size %d\n", fd, size);
return ceph_posix_internal_truncate(fr, size);
} else {
return -EBADF;
}
}

int ceph_posix_truncate(XrdOucEnv* env, const char *pathname, unsigned long long size) {
logwrapper((char*)"ceph_posix_truncate : %s\n", pathname);
// minimal stat : only size and times are filled
CephFile file = getCephFile(pathname, env);
return ceph_posix_internal_truncate(file, size);
}

int ceph_posix_unlink(XrdOucEnv* env, const char *pathname) {
logwrapper((char*)"ceph_posix_unlink : %s\n", pathname);
// minimal stat : only size and times are filled
Expand Down
1 change: 1 addition & 0 deletions src/XrdCeph/ceph_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ int ceph_posix_flistxattrs(int fd, XrdSysXAttr::AList **aPL, int getSz);
void ceph_posix_freexattrlist(XrdSysXAttr::AList *aPL);
int ceph_posix_statfs(long long *totalSpace, long long *freeSpace);
int ceph_posix_truncate(XrdOucEnv* env, const char *pathname, unsigned long long size);
int ceph_posix_ftruncate(int fd, unsigned long long size);
int ceph_posix_unlink(XrdOucEnv* env, const char *pathname);
DIR* ceph_posix_opendir(XrdOucEnv* env, const char *pathname);
int ceph_posix_readdir(DIR* dirp, char *buff, int blen);
Expand Down

0 comments on commit 7f0ef2d

Please sign in to comment.