XRootD
Loading...
Searching...
No Matches
XrdCephOssFile Class Reference

#include <XrdCephOssFile.hh>

Inheritance diagram for XrdCephOssFile:
Collaboration diagram for XrdCephOssFile:

Public Member Functions

 XrdCephOssFile (XrdCephOss *cephoss)
virtual ~XrdCephOssFile ()
virtual int Close (long long *retsz=0)
virtual int Fstat (struct stat *buff)
virtual int Fsync (void)
virtual int Ftruncate (unsigned long long)
virtual int getFileDescriptor () const
virtual int Open (const char *path, int flags, mode_t mode, XrdOucEnv &env)
virtual ssize_t Read (off_t offset, size_t blen)
virtual ssize_t Read (void *buff, off_t offset, size_t blen)
virtual int Read (XrdSfsAio *aoip)
virtual ssize_t ReadRaw (void *, off_t, size_t)
virtual ssize_t ReadV (XrdOucIOVec *readV, int n)
virtual ssize_t Write (const void *buff, off_t offset, size_t blen)
virtual int Write (XrdSfsAio *aiop)
Public Member Functions inherited from XrdOssDF
 XrdOssDF (const char *tid="", uint16_t dftype=0, int fdnum=-1)
virtual ~XrdOssDF ()
uint16_t DFType ()
virtual int Fchmod (mode_t mode)
virtual int Fctl (int cmd, int alen, const char *args, char **resp=0)
virtual void Flush ()
 Flush filesystem cached pages for this file (used for checksums).
virtual int Fsync (XrdSfsAio *aiop)
virtual int getFD ()
virtual off_t getMmap (void **addr)
virtual const char * getTID ()
virtual int isCompressed (char *cxidp=0)
virtual int Opendir (const char *path, XrdOucEnv &env)
virtual ssize_t pgRead (void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
virtual int pgRead (XrdSfsAio *aioparm, uint64_t opts)
virtual ssize_t pgWrite (void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
virtual int pgWrite (XrdSfsAio *aioparm, uint64_t opts)
virtual int Readdir (char *buff, int blen)
virtual int StatRet (struct stat *buff)
virtual ssize_t WriteV (XrdOucIOVec *writeV, int wrvcnt)

Protected Attributes

XrdCephOssm_cephOss
int m_fd
Protected Attributes inherited from XrdOssDF
uint16_t dfType
int fd
off_t pgwEOF
short rsvd
const char * tident

Additional Inherited Members

Static Public Attributes inherited from XrdOssDF
static const uint16_t DF_isDir = 0x0001
 Object is for a directory.
static const uint16_t DF_isFile = 0x0002
 Object is for a file.
static const uint16_t DF_isProxy = 0x0010
 Object is a proxy object.
static const uint64_t doCalc = 0x4000000000000000ULL
 pgw: Calculate checksums
static const int Fctl_ckpObj = 0
static const int Fctl_utimes = 1
static const uint64_t Verify = 0x8000000000000000ULL
 all: Verify checksums

Detailed Description

This class implements XrdOssDF interface for usage with a CEPH storage.

This plugin is able to use any pool of ceph with any userId. There are several ways to provide the pool and userId to be used for a given operation. Here is the ordered list of possibilities. First one defined wins :

  • the path can be prepended with userId and pool. Syntax is : [[userId@]pool:]<actual path>
  • the XrdOucEnv parameter, when existing, can have 'cephUserId' and/or 'cephPool' entries
  • the ofs.osslib directive can provide an argument with format : [userID@]pool
  • default are 'admin' and 'default' for userId and pool respectively

Note that the definition of a default via the ofs.osslib directive may clash with one used in a ofs.xattrlib directive. In case both directives have a default and they are different, the behavior is not defined. In case one of the two only has a default, it will be applied for both plugins.

Definition at line 52 of file XrdCephOssFile.hh.

Constructor & Destructor Documentation

◆ XrdCephOssFile()

XrdCephOssFile::XrdCephOssFile ( XrdCephOss * cephoss)
explicit

Definition at line 39 of file XrdCephOssFile.cc.

39: m_fd(-1), m_cephOss(cephOss) {}
XrdCephOss * m_cephOss

References m_cephOss, and m_fd.

Referenced by XrdCephOssBufferedFile::XrdCephOssBufferedFile(), and XrdCephOssReadVFile::XrdCephOssReadVFile().

Here is the caller graph for this function:

◆ ~XrdCephOssFile()

virtual XrdCephOssFile::~XrdCephOssFile ( )
inlinevirtual

Definition at line 57 of file XrdCephOssFile.hh.

57{};

Member Function Documentation

◆ Close()

int XrdCephOssFile::Close ( long long * retsz = 0)
virtual

Close a directory or file.

Parameters
retszIf not nil, where the size of the file is to be returned.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 53 of file XrdCephOssFile.cc.

53 {
54 return ceph_posix_close(m_fd);
55}
int ceph_posix_close(int fd)

References ceph_posix_close(), and m_fd.

Here is the call graph for this function:

◆ Fstat()

int XrdCephOssFile::Fstat ( struct stat * buf)
virtual

Return state information for this file.

Parameters
buf- Pointer to the structure where info it to be returned.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 113 of file XrdCephOssFile.cc.

113 {
114 return ceph_posix_fstat(m_fd, buff);
115}
int ceph_posix_fstat(int fd, struct stat *buf)

References ceph_posix_fstat(), m_fd, and stat.

Here is the call graph for this function:

◆ Fsync()

int XrdCephOssFile::Fsync ( void )
virtual

Synchronize associated file with media (synchronous).

Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 130 of file XrdCephOssFile.cc.

130 {
131 return ceph_posix_fsync(m_fd);
132}
int ceph_posix_fsync(int fd)

References ceph_posix_fsync(), and m_fd.

Here is the call graph for this function:

◆ Ftruncate()

int XrdCephOssFile::Ftruncate ( unsigned long long flen)
virtual

Set the size of the associated file.

Parameters
flen- The new size of the file.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 134 of file XrdCephOssFile.cc.

134 {
135 return ceph_posix_ftruncate(m_fd, len);
136}
int ceph_posix_ftruncate(int fd, unsigned long long size)

References ceph_posix_ftruncate(), and m_fd.

Here is the call graph for this function:

◆ getFileDescriptor()

virtual int XrdCephOssFile::getFileDescriptor ( ) const
inlinevirtual

Definition at line 71 of file XrdCephOssFile.hh.

71{return m_fd;}

References m_fd.

◆ Open()

int XrdCephOssFile::Open ( const char * path,
int Oflag,
mode_t Mode,
XrdOucEnv & env )
virtual

Open a file.

Parameters
path- Pointer to the path of the file to be opened.
Oflag- Standard open flags.
Mode- File open mode (ignored unless creating a file).
env- Reference to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 41 of file XrdCephOssFile.cc.

41 {
42 try {
43 int rc = ceph_posix_open(&env, path, flags, mode);
44 if (rc < 0) return rc;
45 m_fd = rc;
46 return XrdOssOK;
47 } catch (std::exception &e) {
48 XrdCephEroute.Say("open : invalid syntax in file parameters");
49 return -EINVAL;
50 }
51}
XrdSysError XrdCephEroute(0)
Definition XrdCephOss.cc:50
int ceph_posix_open(XrdOucEnv *env, const char *pathname, int flags, mode_t mode)
#define XrdOssOK
Definition XrdOss.hh:50
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)

References ceph_posix_open(), m_fd, XrdCephEroute, and XrdOssOK.

Here is the call graph for this function:

◆ Read() [1/3]

ssize_t XrdCephOssFile::Read ( off_t offset,
size_t size )
virtual

Preread file blocks into the file system cache.

Parameters
offset- The offset where the read is to start.
size- The number of bytes to pre-read.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 57 of file XrdCephOssFile.cc.

57 {
58 return XrdOssOK;
59}

References XrdOssOK.

Referenced by ReadRaw().

Here is the caller graph for this function:

◆ Read() [2/3]

ssize_t XrdCephOssFile::Read ( void * buffer,
off_t offset,
size_t size )
virtual

Read file bytes into a buffer.

Parameters
buffer- pointer to buffer where the bytes are to be placed.
offset- The offset where the read is to start.
size- The number of bytes to read.
Returns
>= 0 The number of bytes that placed in buffer.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 61 of file XrdCephOssFile.cc.

61 {
62 ssize_t retval;
63 if (m_cephOss->m_useDefaultPreadAlg) {
64 retval = ceph_posix_pread(m_fd, buff, blen, offset);
65 } else {
66 retval = ceph_posix_nonstriper_pread(m_fd, buff, blen, offset);
67 if (-ENOENT == retval || -ENOTSUP == retval) {
68 //This might be a sparse file or nbstripes > 1, so let's try striper read
69 retval = ceph_posix_pread(m_fd, buff, blen, offset);
70 if (retval >= 0) {
71 char err_str[100]; //99 symbols should be enough for the short message
72 snprintf(err_str, 100, "WARNING! The file (fd %d) seem to be sparse, this is not expected", m_fd);
73 XrdCephEroute.Say(err_str);
74 }
75 }
76 }
77 return retval;
78}
ssize_t ceph_posix_pread(int fd, void *buf, size_t count, off64_t offset)
ssize_t ceph_posix_nonstriper_pread(int fd, void *buf, size_t count, off64_t offset)

References ceph_posix_nonstriper_pread(), ceph_posix_pread(), m_cephOss, m_fd, and XrdCephEroute.

Here is the call graph for this function:

◆ Read() [3/3]

int XrdCephOssFile::Read ( XrdSfsAio * aiop)
virtual

Read file bytes using asynchronous I/O.

Parameters
aiop- Pointer to async I/O object controlling the I/O.
Returns
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 85 of file XrdCephOssFile.cc.

85 {
86 return ceph_aio_read(m_fd, aiop, aioReadCallback);
87}
static void aioReadCallback(XrdSfsAio *aiop, size_t rc)
ssize_t ceph_aio_read(int fd, XrdSfsAio *aiop, AioCB *cb)

References aioReadCallback(), ceph_aio_read(), and m_fd.

Here is the call graph for this function:

◆ ReadRaw()

ssize_t XrdCephOssFile::ReadRaw ( void * buffer,
off_t offset,
size_t size )
virtual

Read uncompressed file bytes into a buffer.

Parameters
buffer- pointer to buffer where the bytes are to be placed.
offset- The offset where the read is to start.
size- The number of bytes to read.
Returns
>= 0 The number of bytes that placed in buffer.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 89 of file XrdCephOssFile.cc.

89 {
90 return Read(buff, offset, blen);
91}
virtual ssize_t Read(off_t offset, size_t blen)

References Read().

Here is the call graph for this function:

◆ ReadV()

ssize_t XrdCephOssFile::ReadV ( XrdOucIOVec * readV,
int rdvcnt )
virtual

Read file bytes as directed by the read vector.

Parameters
readVpointer to the array of read requests.
rdvcntthe number of elements in readV.
Returns
>=0 The numbe of bytes read.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 93 of file XrdCephOssFile.cc.

93 {
94 ssize_t retval;
95 if (m_cephOss->m_useDefaultReadvAlg) {
96 retval = ceph_striper_readv(m_fd, readV, n);
97 } else {
98 retval = ceph_nonstriper_readv(m_fd, readV, n);
99 if (-ENOENT == retval || -ENOTSUP == retval) {
100 //This might be a sparse file or nbstripes > 1, so let's try striper read
101 retval = ceph_striper_readv(m_fd, readV, n);
102 if (retval >= 0) {
103 char err_str[100]; //99 symbols should be enough for the short message
104 snprintf(err_str, 100, "WARNING! The file (fd %d) seem to be sparse, this is not expected", m_fd);
105 XrdCephEroute.Say(err_str);
106 }
107 }
108 }
109 return retval;
110}
ssize_t ceph_nonstriper_readv(int fd, XrdOucIOVec *readV, int n)
ssize_t ceph_striper_readv(int fd, XrdOucIOVec *readV, int n)

References ceph_nonstriper_readv(), ceph_striper_readv(), m_cephOss, m_fd, and XrdCephEroute.

Here is the call graph for this function:

◆ Write() [1/2]

ssize_t XrdCephOssFile::Write ( const void * buffer,
off_t offset,
size_t size )
virtual

Write file bytes from a buffer.

Parameters
buffer- pointer to buffer where the bytes reside.
offset- The offset where the write is to start.
size- The number of bytes to write.
Returns
>= 0 The number of bytes that were written.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 117 of file XrdCephOssFile.cc.

117 {
118 return ceph_posix_pwrite(m_fd, buff, blen, offset);
119}
ssize_t ceph_posix_pwrite(int fd, const void *buf, size_t count, off64_t offset)

References ceph_posix_pwrite(), and m_fd.

Here is the call graph for this function:

◆ Write() [2/2]

int XrdCephOssFile::Write ( XrdSfsAio * aiop)
virtual

Write file bytes using asynchronous I/O.

Parameters
aiop- Pointer to async I/O object controlling the I/O.
Returns
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Reimplemented in XrdCephOssBufferedFile, and XrdCephOssReadVFile.

Definition at line 126 of file XrdCephOssFile.cc.

126 {
127 return ceph_aio_write(m_fd, aiop, aioWriteCallback);
128}
static void aioWriteCallback(XrdSfsAio *aiop, size_t rc)
ssize_t ceph_aio_write(int fd, XrdSfsAio *aiop, AioCB *cb)

References aioWriteCallback(), ceph_aio_write(), and m_fd.

Here is the call graph for this function:

Member Data Documentation

◆ m_cephOss

XrdCephOss* XrdCephOssFile::m_cephOss
protected

Definition at line 75 of file XrdCephOssFile.hh.

Referenced by XrdCephOssFile(), Read(), and ReadV().

◆ m_fd


The documentation for this class was generated from the following files: