glupy patch by Ram, Justin: Add/Modify fops, structure types, utility fns
Extend the following fops with Python: * open * readv * writev * opendir * readdir * readdirp * stat * fstat * statfs * setxattr * getxattr * fsetxattr * fgetxattr * removexattr * fremovexattr * link * unlink * readlink * symlink * mkdir * rmdir Add fd_t, inode_t and iatt_t structure types. Modify loc_t structure type; Alter the data types of the following attributes - inode, parent, gfid, pargfid. Modify uuid2str function, which returns a string equivalent for a ctype object representing a gfid, to make use of python's 'uuid' module for accurate representation of uuids. by Justin Clift: Adjust debug-trace.py to work with Python 2.6 Work around 'zero length field name in format' bug in negative.py's uuid2str function Fix indentation errors in negative.py, glupy.h, glupy.c, gluster.py Change-Id: If0fcfb2866e21c0380a973f8ffab9ea7b6a4cd5d BUG: 961856 Signed-off-by: Ram Raja <rraja@redhat.com> Reviewed-on: http://review.gluster.org/4907 Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-by: Justin Clift <jclift@redhat.com> Tested-by: Justin Clift <jclift@redhat.com>
This commit is contained in:
parent
b9fdbc0790
commit
68712c33b4
9
xlators/features/glupy/doc/TESTING
Normal file
9
xlators/features/glupy/doc/TESTING
Normal file
@ -0,0 +1,9 @@
|
||||
Loading a translator written in Python using the glupy meta translator
|
||||
-------------------------------------------------------------------------------
|
||||
'test.vol' is a simple volfile with the debug-trace Python translator on top
|
||||
of a brick. The volfile can be mounted using the following command.
|
||||
|
||||
$ glusterfs --debug -f test.vol /path/to/mntpt
|
||||
|
||||
If then file operations are performed on the newly mounted file system, log
|
||||
output would be printed by the Python translator on the standard output.
|
10
xlators/features/glupy/doc/test.vol
Normal file
10
xlators/features/glupy/doc/test.vol
Normal file
@ -0,0 +1,10 @@
|
||||
volume vol-posix
|
||||
type storage/posix
|
||||
option directory /path/to/brick
|
||||
end-volume
|
||||
|
||||
volume vol-glupy
|
||||
type features/glupy
|
||||
option module-name debug-trace
|
||||
subvolumes vol-posix
|
||||
end-volume
|
@ -4,7 +4,7 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features
|
||||
|
||||
glupydir = $(xlatordir)/glupy
|
||||
|
||||
glupy_PYTHON = gluster.py negative.py helloworld.py
|
||||
glupy_PYTHON = gluster.py negative.py helloworld.py debug-trace.py
|
||||
|
||||
glupy_la_LDFLAGS = -module -avoid-version -shared -nostartfiles
|
||||
glupy_la_SOURCES = glupy.c
|
||||
|
774
xlators/features/glupy/src/debug-trace.py
Normal file
774
xlators/features/glupy/src/debug-trace.py
Normal file
@ -0,0 +1,774 @@
|
||||
import sys
|
||||
import stat
|
||||
from uuid import UUID
|
||||
from time import strftime, localtime
|
||||
from gluster import *
|
||||
# This translator was written primarily to test the fop entry point definitions
|
||||
# and structure definitions in 'gluster.py'.
|
||||
# It is similar to the debug-trace translator, one of the already available
|
||||
# translator types written in C, that logs the arguments passed to the fops and
|
||||
# their corresponding cbk functions.
|
||||
|
||||
dl.get_id.restype = c_long
|
||||
dl.get_id.argtypes = [ POINTER(call_frame_t) ]
|
||||
|
||||
dl.get_rootunique.restype = c_uint64
|
||||
dl.get_rootunique.argtypes = [ POINTER(call_frame_t) ]
|
||||
|
||||
def uuid2str (gfid):
|
||||
return str(UUID(''.join(map("{0:02x}".format, gfid))))
|
||||
|
||||
|
||||
def st_mode_from_ia (prot, filetype):
|
||||
st_mode = 0
|
||||
type_bit = 0
|
||||
prot_bit = 0
|
||||
|
||||
if filetype == IA_IFREG:
|
||||
type_bit = stat.S_IFREG
|
||||
elif filetype == IA_IFDIR:
|
||||
type_bit = stat.S_IFDIR
|
||||
elif filetype == IA_IFLNK:
|
||||
type_bit = stat.S_IFLNK
|
||||
elif filetype == IA_IFBLK:
|
||||
type_bit = stat.S_IFBLK
|
||||
elif filetype == IA_IFCHR:
|
||||
type_bit = stat.S_IFCHR
|
||||
elif filetype == IA_IFIFO:
|
||||
type_bit = stat.S_IFIFO
|
||||
elif filetype == IA_IFSOCK:
|
||||
type_bit = stat.S_IFSOCK
|
||||
elif filetype == IA_INVAL:
|
||||
pass
|
||||
|
||||
|
||||
if prot.suid:
|
||||
prot_bit |= stat.S_ISUID
|
||||
if prot.sgid:
|
||||
prot_bit |= stat.S_ISGID
|
||||
if prot.sticky:
|
||||
prot_bit |= stat.S_ISVTX
|
||||
|
||||
if prot.owner.read:
|
||||
prot_bit |= stat.S_IRUSR
|
||||
if prot.owner.write:
|
||||
prot_bit |= stat.S_IWUSR
|
||||
if prot.owner.execn:
|
||||
prot_bit |= stat.S_IXUSR
|
||||
|
||||
if prot.group.read:
|
||||
prot_bit |= stat.S_IRGRP
|
||||
if prot.group.write:
|
||||
prot_bit |= stat.S_IWGRP
|
||||
if prot.group.execn:
|
||||
prot_bit |= stat.S_IXGRP
|
||||
|
||||
if prot.other.read:
|
||||
prot_bit |= stat.S_IROTH
|
||||
if prot.other.write:
|
||||
prot_bit |= stat.S_IWOTH
|
||||
if prot.other.execn:
|
||||
prot_bit |= stat.S_IXOTH
|
||||
|
||||
st_mode = (type_bit | prot_bit)
|
||||
|
||||
return st_mode
|
||||
|
||||
|
||||
def trace_stat2str (buf):
|
||||
gfid = uuid2str(buf.contents.ia_gfid)
|
||||
mode = st_mode_from_ia(buf.contents.ia_prot, buf.contents.ia_type)
|
||||
atime_buf = strftime("[%b %d %H:%M:%S]",
|
||||
localtime(buf.contents.ia_atime))
|
||||
mtime_buf = strftime("[%b %d %H:%M:%S]",
|
||||
localtime(buf.contents.ia_mtime))
|
||||
ctime_buf = strftime("[%b %d %H:%M:%S]",
|
||||
localtime(buf.contents.ia_ctime))
|
||||
return ("(gfid={0:s}, ino={1:d}, mode={2:o}, nlink={3:d}, uid ={4:d}, "+
|
||||
"gid ={5:d}, size={6:d}, blocks={7:d}, atime={8:s}, mtime={9:s}, "+
|
||||
"ctime={10:s})").format(gfid, buf.contents.ia_no, mode,
|
||||
buf.contents.ia_nlink,
|
||||
buf.contents.ia_uid,
|
||||
buf.contents.ia_gid,
|
||||
buf.contents.ia_size,
|
||||
buf.contents.ia_blocks,
|
||||
atime_buf, mtime_buf,
|
||||
ctime_buf)
|
||||
|
||||
class xlator(Translator):
|
||||
|
||||
def __init__(self, c_this):
|
||||
Translator.__init__(self, c_this)
|
||||
self.gfids = {}
|
||||
|
||||
def lookup_fop(self, frame, this, loc, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.gfid)
|
||||
print("GLUPY TRACE LOOKUP FOP- {0:d}: gfid={1:s}; " +
|
||||
"path={2:s}").format(unique, gfid, loc.contents.path)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_lookup(frame, POINTER(xlator_t)(), loc, xdata)
|
||||
return 0
|
||||
|
||||
def lookup_cbk(self, frame, cookie, this, op_ret, op_errno,
|
||||
inode, buf, xdata, postparent):
|
||||
unique =dl.get_rootunique(frame)
|
||||
key =dl.get_id(frame)
|
||||
if op_ret == 0:
|
||||
gfid = uuid2str(buf.contents.ia_gfid)
|
||||
statstr = trace_stat2str(buf)
|
||||
postparentstr = trace_stat2str(postparent)
|
||||
print("GLUPY TRACE LOOKUP CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; *buf={3:s}; " +
|
||||
"*postparent={4:s}").format(unique, gfid,
|
||||
op_ret, statstr,
|
||||
postparentstr)
|
||||
else:
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE LOOKUP CBK - {0:d}: gfid={1:s};" +
|
||||
" op_ret={2:d}; op_errno={3:d}").format(unique,
|
||||
gfid,
|
||||
op_ret,
|
||||
op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_lookup(frame, cookie, this, op_ret, op_errno,
|
||||
inode, buf, xdata, postparent)
|
||||
return 0
|
||||
|
||||
def create_fop(self, frame, this, loc, flags, mode, umask, fd,
|
||||
xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
gfid = uuid2str(loc.contents.gfid)
|
||||
print("GLUPY TRACE CREATE FOP- {0:d}: gfid={1:s}; path={2:s}; " +
|
||||
"fd={3:s}; flags=0{4:o}; mode=0{5:o}; " +
|
||||
"umask=0{6:o}").format(unique, gfid, loc.contents.path,
|
||||
fd, flags, mode, umask)
|
||||
dl.wind_create(frame, POINTER(xlator_t)(), loc, flags,mode,
|
||||
umask, fd, xdata)
|
||||
return 0
|
||||
|
||||
def create_cbk(self, frame, cookie, this, op_ret, op_errno, fd,
|
||||
inode, buf, preparent, postparent, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
if op_ret >= 0:
|
||||
gfid = uuid2str(inode.contents.gfid)
|
||||
statstr = trace_stat2str(buf)
|
||||
preparentstr = trace_stat2str(preparent)
|
||||
postparentstr = trace_stat2str(postparent)
|
||||
print("GLUPY TRACE CREATE CBK- {0:d}: gfid={1:s};" +
|
||||
" op_ret={2:d}; fd={3:s}; *stbuf={4:s}; " +
|
||||
"*preparent={5:s};" +
|
||||
" *postparent={6:s}").format(unique, gfid, op_ret,
|
||||
fd, statstr,
|
||||
preparentstr,
|
||||
postparentstr)
|
||||
else:
|
||||
print ("GLUPY TRACE CREATE CBK- {0:d}: op_ret={1:d}; " +
|
||||
"op_errno={2:d}").format(unique, op_ret, op_errno)
|
||||
dl.unwind_create(frame, cookie, this, op_ret, op_errno, fd,
|
||||
inode, buf, preparent, postparent, xdata)
|
||||
return 0
|
||||
|
||||
def open_fop(self, frame, this, loc, flags, fd, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE OPEN FOP- {0:d}: gfid={1:s}; path={2:s}; "+
|
||||
"flags={3:d}; fd={4:s}").format(unique, gfid,
|
||||
loc.contents.path, flags,
|
||||
fd)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_open(frame, POINTER(xlator_t)(), loc, flags, fd, xdata)
|
||||
return 0
|
||||
|
||||
def open_cbk(self, frame, cookie, this, op_ret, op_errno, fd, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE OPEN CBK- {0:d}: gfid={1:s}; op_ret={2:d}; "
|
||||
"op_errno={3:d}; *fd={4:s}").format(unique, gfid,
|
||||
op_ret, op_errno, fd)
|
||||
del self.gfids[key]
|
||||
dl.unwind_open(frame, cookie, this, op_ret, op_errno, fd,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def readv_fop(self, frame, this, fd, size, offset, flags, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(fd.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE READV FOP- {0:d}: gfid={1:s}; "+
|
||||
"fd={2:s}; size ={3:d}; offset={4:d}; " +
|
||||
"flags=0{5:x}").format(unique, gfid, fd, size, offset,
|
||||
flags)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_readv (frame, POINTER(xlator_t)(), fd, size, offset,
|
||||
flags, xdata)
|
||||
return 0
|
||||
|
||||
def readv_cbk(self, frame, cookie, this, op_ret, op_errno, vector,
|
||||
count, buf, iobref, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
if op_ret >= 0:
|
||||
statstr = trace_stat2str(buf)
|
||||
print("GLUPY TRACE READV CBK- {0:d}: gfid={1:s}, "+
|
||||
"op_ret={2:d}; *buf={3:s};").format(unique, gfid,
|
||||
op_ret,
|
||||
statstr)
|
||||
|
||||
else:
|
||||
print("GLUPY TRACE READV CBK- {0:d}: gfid={1:s}, "+
|
||||
"op_ret={2:d}; op_errno={3:d}").format(unique,
|
||||
gfid,
|
||||
op_ret,
|
||||
op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_readv (frame, cookie, this, op_ret, op_errno,
|
||||
vector, count, buf, iobref, xdata)
|
||||
return 0
|
||||
|
||||
def writev_fop(self, frame, this, fd, vector, count, offset, flags,
|
||||
iobref, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(fd.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE WRITEV FOP- {0:d}: gfid={1:s}; " +
|
||||
"fd={2:s}; count={3:d}; offset={4:d}; " +
|
||||
"flags=0{5:x}").format(unique, gfid, fd, count, offset,
|
||||
flags)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_writev(frame, POINTER(xlator_t)(), fd, vector, count,
|
||||
offset, flags, iobref, xdata)
|
||||
return 0
|
||||
|
||||
def writev_cbk(self, frame, cookie, this, op_ret, op_errno, prebuf,
|
||||
postbuf, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
if op_ret >= 0:
|
||||
preopstr = trace_stat2str(prebuf)
|
||||
postopstr = trace_stat2str(postbuf)
|
||||
print("GLUPY TRACE WRITEV CBK- {0:d}: op_ret={1:d}; " +
|
||||
"*prebuf={2:s}; " +
|
||||
"*postbuf={3:s}").format(unique, op_ret, preopstr,
|
||||
postopstr)
|
||||
else:
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE WRITEV CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; op_errno={3:d}").format(unique,
|
||||
gfid,
|
||||
op_ret,
|
||||
op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_writev (frame, cookie, this, op_ret, op_errno,
|
||||
prebuf, postbuf, xdata)
|
||||
return 0
|
||||
|
||||
def opendir_fop(self, frame, this, loc, fd, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE OPENDIR FOP- {0:d}: gfid={1:s}; path={2:s}; "+
|
||||
"fd={3:s}").format(unique, gfid, loc.contents.path, fd)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_opendir(frame, POINTER(xlator_t)(), loc, fd, xdata)
|
||||
return 0
|
||||
|
||||
def opendir_cbk(self, frame, cookie, this, op_ret, op_errno, fd,
|
||||
xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE OPENDIR CBK- {0:d}: gfid={1:s}; op_ret={2:d};"+
|
||||
" op_errno={3:d}; fd={4:s}").format(unique, gfid, op_ret,
|
||||
op_errno, fd)
|
||||
del self.gfids[key]
|
||||
dl.unwind_opendir(frame, cookie, this, op_ret, op_errno,
|
||||
fd, xdata)
|
||||
return 0
|
||||
|
||||
def readdir_fop(self, frame, this, fd, size, offset, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(fd.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE READDIR FOP- {0:d}: gfid={1:s}; fd={2:s}; " +
|
||||
"size={3:d}; offset={4:d}").format(unique, gfid, fd, size,
|
||||
offset)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_readdir(frame, POINTER(xlator_t)(), fd, size, offset,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def readdir_cbk(self, frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE READDIR CBK- {0:d}: gfid={1:s}; op_ret={2:d};"+
|
||||
" op_errno={3:d}").format(unique, gfid, op_ret, op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_readdir(frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def readdirp_fop(self, frame, this, fd, size, offset, dictionary):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(fd.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE READDIRP FOP- {0:d}: gfid={1:s}; fd={2:s}; "+
|
||||
" size={3:d}; offset={4:d}").format(unique, gfid, fd, size,
|
||||
offset)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_readdirp(frame, POINTER(xlator_t)(), fd, size, offset,
|
||||
dictionary)
|
||||
return 0
|
||||
|
||||
def readdirp_cbk(self, frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE READDIRP CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; op_errno={3:d}").format(unique, gfid,
|
||||
op_ret, op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_readdirp(frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def mkdir_fop(self, frame, this, loc, mode, umask, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE MKDIR FOP- {0:d}: gfid={1:s}; path={2:s}; " +
|
||||
"mode={3:d}; umask=0{4:o}").format(unique, gfid,
|
||||
loc.contents.path, mode,
|
||||
umask)
|
||||
dl.wind_mkdir(frame, POINTER(xlator_t)(), loc, mode, umask,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def mkdir_cbk(self, frame, cookie, this, op_ret, op_errno, inode, buf,
|
||||
preparent, postparent, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
if op_ret == 0:
|
||||
gfid = uuid2str(inode.contents.gfid)
|
||||
statstr = trace_stat2str(buf)
|
||||
preparentstr = trace_stat2str(preparent)
|
||||
postparentstr = trace_stat2str(postparent)
|
||||
print("GLUPY TRACE MKDIR CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; *stbuf={3:s}; *prebuf={4:s}; "+
|
||||
"*postbuf={5:s} ").format(unique, gfid, op_ret,
|
||||
statstr,
|
||||
preparentstr,
|
||||
postparentstr)
|
||||
else:
|
||||
print("GLUPY TRACE MKDIR CBK- {0:d}: op_ret={1:d}; "+
|
||||
"op_errno={2:d}").format(unique, op_ret, op_errno)
|
||||
dl.unwind_mkdir(frame, cookie, this, op_ret, op_errno, inode,
|
||||
buf, preparent, postparent, xdata)
|
||||
return 0
|
||||
|
||||
def rmdir_fop(self, frame, this, loc, flags, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE RMDIR FOP- {0:d}: gfid={1:s}; path={2:s}; "+
|
||||
"flags={3:d}").format(unique, gfid, loc.contents.path,
|
||||
flags)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_rmdir(frame, POINTER(xlator_t)(), loc, flags, xdata)
|
||||
return 0
|
||||
|
||||
def rmdir_cbk(self, frame, cookie, this, op_ret, op_errno, preparent,
|
||||
postparent, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
if op_ret == 0:
|
||||
preparentstr = trace_stat2str(preparent)
|
||||
postparentstr = trace_stat2str(postparent)
|
||||
print("GLUPY TRACE RMDIR CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; *prebuf={3:s}; "+
|
||||
"*postbuf={4:s}").format(unique, gfid, op_ret,
|
||||
preparentstr,
|
||||
postparentstr)
|
||||
else:
|
||||
print("GLUPY TRACE RMDIR CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; op_errno={3:d}").format(unique,
|
||||
gfid,
|
||||
op_ret,
|
||||
op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_rmdir(frame, cookie, this, op_ret, op_errno,
|
||||
preparent, postparent, xdata)
|
||||
return 0
|
||||
|
||||
def stat_fop(self, frame, this, loc, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE STAT FOP- {0:d}: gfid={1:s}; " +
|
||||
" path={2:s}").format(unique, gfid, loc.contents.path)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_stat(frame, POINTER(xlator_t)(), loc, xdata)
|
||||
return 0
|
||||
|
||||
def stat_cbk(self, frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
if op_ret == 0:
|
||||
statstr = trace_stat2str(buf)
|
||||
print("GLUPY TRACE STAT CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; *buf={3:s};").format(unique,
|
||||
gfid,
|
||||
op_ret,
|
||||
statstr)
|
||||
else:
|
||||
print("GLUPY TRACE STAT CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; op_errno={3:d}").format(unique,
|
||||
gfid,
|
||||
op_ret,
|
||||
op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_stat(frame, cookie, this, op_ret, op_errno,
|
||||
buf, xdata)
|
||||
return 0
|
||||
|
||||
def fstat_fop(self, frame, this, fd, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(fd.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE FSTAT FOP- {0:d}: gfid={1:s}; " +
|
||||
"fd={2:s}").format(unique, gfid, fd)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_fstat(frame, POINTER(xlator_t)(), fd, xdata)
|
||||
return 0
|
||||
|
||||
def fstat_cbk(self, frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
if op_ret == 0:
|
||||
statstr = trace_stat2str(buf)
|
||||
print("GLUPY TRACE FSTAT CBK- {0:d}: gfid={1:s} "+
|
||||
" op_ret={2:d}; *buf={3:s}").format(unique,
|
||||
gfid,
|
||||
op_ret,
|
||||
statstr)
|
||||
else:
|
||||
print("GLUPY TRACE FSTAT CBK- {0:d}: gfid={1:s} "+
|
||||
"op_ret={2:d}; op_errno={3:d}").format(unique.
|
||||
gfid,
|
||||
op_ret,
|
||||
op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_fstat(frame, cookie, this, op_ret, op_errno,
|
||||
buf, xdata)
|
||||
return 0
|
||||
|
||||
def statfs_fop(self, frame, this, loc, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
if loc.contents.inode:
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
else:
|
||||
gfid = "0"
|
||||
print("GLUPY TRACE STATFS FOP- {0:d}: gfid={1:s}; "+
|
||||
"path={2:s}").format(unique, gfid, loc.contents.path)
|
||||
dl.wind_statfs(frame, POINTER(xlator_t)(), loc, xdata)
|
||||
return 0
|
||||
|
||||
def statfs_cbk(self, frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
if op_ret == 0:
|
||||
#TBD: print buf (pointer to an iovec type object)
|
||||
print("GLUPY TRACE STATFS CBK {0:d}: "+
|
||||
"op_ret={1:d}").format(unique, op_ret)
|
||||
else:
|
||||
print("GLUPY TRACE STATFS CBK- {0:d}"+
|
||||
"op_ret={1:d}; op_errno={2:d}").format(unique,
|
||||
op_ret,
|
||||
op_errno)
|
||||
dl.unwind_statfs(frame, cookie, this, op_ret, op_errno,
|
||||
buf, xdata)
|
||||
return 0
|
||||
|
||||
def getxattr_fop(self, frame, this, loc, name, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE GETXATTR FOP- {0:d}: gfid={1:s}; path={2:s};"+
|
||||
" name={3:s}").format(unique, gfid, loc.contents.path,
|
||||
name)
|
||||
self.gfids[key]=gfid
|
||||
dl.wind_getxattr(frame, POINTER(xlator_t)(), loc, name, xdata)
|
||||
return 0
|
||||
|
||||
def getxattr_cbk(self, frame, cookie, this, op_ret, op_errno,
|
||||
dictionary, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE GETXATTR CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; op_errno={3:d}; "+
|
||||
" dictionary={4:s}").format(unique, gfid, op_ret, op_errno,
|
||||
dictionary)
|
||||
del self.gfids[key]
|
||||
dl.unwind_getxattr(frame, cookie, this, op_ret, op_errno,
|
||||
dictionary, xdata)
|
||||
return 0
|
||||
|
||||
def fgetxattr_fop(self, frame, this, fd, name, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(fd.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE FGETXATTR FOP- {0:d}: gfid={1:s}; fd={2:s}; "+
|
||||
"name={3:s}").format(unique, gfid, fd, name)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_fgetxattr(frame, POINTER(xlator_t)(), fd, name, xdata)
|
||||
return 0
|
||||
|
||||
def fgetxattr_cbk(self, frame, cookie, this, op_ret, op_errno,
|
||||
dictionary, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE FGETXATTR CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; op_errno={3:d};"+
|
||||
" dictionary={4:s}").format(unique, gfid, op_ret,
|
||||
op_errno, dictionary)
|
||||
del self.gfids[key]
|
||||
dl.unwind_fgetxattr(frame, cookie, this, op_ret, op_errno,
|
||||
dictionary, xdata)
|
||||
return 0
|
||||
|
||||
def setxattr_fop(self, frame, this, loc, dictionary, flags, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE SETXATTR FOP- {0:d}: gfid={1:s}; path={2:s};"+
|
||||
" flags={3:d}").format(unique, gfid, loc.contents.path,
|
||||
flags)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_setxattr(frame, POINTER(xlator_t)(), loc, dictionary,
|
||||
flags, xdata)
|
||||
return 0
|
||||
|
||||
def setxattr_cbk(self, frame, cookie, this, op_ret, op_errno, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE SETXATTR CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; op_errno={3:d}").format(unique, gfid,
|
||||
op_ret, op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_setxattr(frame, cookie, this, op_ret, op_errno,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def fsetxattr_fop(self, frame, this, fd, dictionary, flags, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(fd.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE FSETXATTR FOP- {0:d}: gfid={1:s}; fd={2:p}; "+
|
||||
"flags={3:d}").format(unique, gfid, fd, flags)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_fsetxattr(frame, POINTER(xlator_t)(), fd, dictionary,
|
||||
flags, xdata)
|
||||
return 0
|
||||
|
||||
def fsetxattr_cbk(self, frame, cookie, this, op_ret, op_errno, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE FSETXATTR CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; op_errno={3:d}").format(unique, gfid,
|
||||
op_ret, op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_fsetxattr(frame, cookie, this, op_ret, op_errno,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def removexattr_fop(self, frame, this, loc, name, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE REMOVEXATTR FOP- {0:d}: gfid={1:s}; "+
|
||||
"path={2:s}; name={3:s}").format(unique, gfid,
|
||||
loc.contents.path,
|
||||
name)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_removexattr(frame, POINTER(xlator_t)(), loc, name,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def removexattr_cbk(self, frame, cookie, this, op_ret, op_errno,
|
||||
xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
print("GLUPY TRACE REMOVEXATTR CBK- {0:d}: gfid={1:s} "+
|
||||
" op_ret={2:d}; op_errno={3:d}").format(unique, gfid,
|
||||
op_ret, op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_removexattr(frame, cookie, this, op_ret, op_errno,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def link_fop(self, frame, this, oldloc, newloc, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
if (newloc.contents.inode):
|
||||
newgfid = uuid2str(newloc.contents.inode.contents.gfid)
|
||||
else:
|
||||
newgfid = "0"
|
||||
oldgfid = uuid2str(oldloc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE LINK FOP-{0:d}: oldgfid={1:s}; oldpath={2:s};"+
|
||||
"newgfid={3:s};"+
|
||||
"newpath={4:s}").format(unique, oldgfid,
|
||||
oldloc.contents.path,
|
||||
newgfid,
|
||||
newloc.contents.path)
|
||||
self.gfids[key] = oldgfid
|
||||
dl.wind_link(frame, POINTER(xlator_t)(), oldloc, newloc,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def link_cbk(self, frame, cookie, this, op_ret, op_errno, inode, buf,
|
||||
preparent, postparent, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
if op_ret == 0:
|
||||
statstr = trace_stat2str(buf)
|
||||
preparentstr = trace_stat2str(preparent)
|
||||
postparentstr = trace_stat2str(postparent)
|
||||
print("GLUPY TRACE LINK CBK- {0:d}: op_ret={1:d} "+
|
||||
"*stbuf={2:s}; *prebuf={3:s}; "+
|
||||
"*postbuf={4:s} ").format(unique, op_ret, statstr,
|
||||
preparentstr,
|
||||
postparentstr)
|
||||
else:
|
||||
print("GLUPY TRACE LINK CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; "+
|
||||
"op_errno={3:d}").format(unique, gfid,
|
||||
op_ret, op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_link(frame, cookie, this, op_ret, op_errno, inode,
|
||||
buf, preparent, postparent, xdata)
|
||||
return 0
|
||||
|
||||
def unlink_fop(self, frame, this, loc, xflag, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE UNLINK FOP- {0:d}; gfid={1:s}; path={2:s}; "+
|
||||
"flag={3:d}").format(unique, gfid, loc.contents.path,
|
||||
xflag)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_unlink(frame, POINTER(xlator_t)(), loc, xflag,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def unlink_cbk(self, frame, cookie, this, op_ret, op_errno,
|
||||
preparent, postparent, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
if op_ret == 0:
|
||||
preparentstr = trace_stat2str(preparent)
|
||||
postparentstr = trace_stat2str(postparent)
|
||||
print("GLUPY TRACE UNLINK CBK- {0:d}: gfid ={1:s}; "+
|
||||
"op_ret={2:d}; *prebuf={3:s}; "+
|
||||
"*postbuf={4:s} ").format(unique, gfid, op_ret,
|
||||
preparentstr,
|
||||
postparentstr)
|
||||
else:
|
||||
print("GLUPY TRACE UNLINK CBK: {0:d}: gfid ={1:s}; "+
|
||||
"op_ret={2:d}; "+
|
||||
"op_errno={3:d}").format(unique, gfid, op_ret,
|
||||
op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_unlink(frame, cookie, this, op_ret, op_errno,
|
||||
preparent, postparent, xdata)
|
||||
return 0
|
||||
|
||||
def readlink_fop(self, frame, this, loc, size, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE READLINK FOP- {0:d}: gfid={1:s}; path={2:s};"+
|
||||
" size={3:d}").format(unique, gfid, loc.contents.path,
|
||||
size)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_readlink(frame, POINTER(xlator_t)(), loc, size,
|
||||
xdata)
|
||||
return 0
|
||||
|
||||
def readlink_cbk(self, frame, cookie, this, op_ret, op_errno,
|
||||
buf, stbuf, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
if op_ret == 0:
|
||||
statstr = trace_stat2str(stbuf)
|
||||
print("GLUPY TRACE READLINK CBK- {0:d}: gfid={1:s} "+
|
||||
" op_ret={2:d}; op_errno={3:d}; *prebuf={4:s}; "+
|
||||
"*postbuf={5:s} ").format(unique, gfid,
|
||||
op_ret, op_errno,
|
||||
buf, statstr)
|
||||
else:
|
||||
print("GLUPY TRACE READLINK CBK- {0:d}: gfid={1:s} "+
|
||||
" op_ret={2:d}; op_errno={3:d}").format(unique,
|
||||
gfid,
|
||||
op_ret,
|
||||
op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_readlink(frame, cookie, this, op_ret, op_errno, buf,
|
||||
stbuf, xdata)
|
||||
return 0
|
||||
|
||||
def symlink_fop(self, frame, this, linkpath, loc, umask, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = uuid2str(loc.contents.inode.contents.gfid)
|
||||
print("GLUPY TRACE SYMLINK FOP- {0:d}: gfid={1:s}; "+
|
||||
"linkpath={2:s}; path={3:s};"+
|
||||
"umask=0{4:o}").format(unique, gfid, linkpath,
|
||||
loc.contents.path, umask)
|
||||
self.gfids[key] = gfid
|
||||
dl.wind_symlink(frame, POINTER(xlator_t)(), linkpath, loc,
|
||||
umask, xdata)
|
||||
return 0
|
||||
|
||||
def symlink_cbk(self, frame, cookie, this, op_ret, op_errno,
|
||||
inode, buf, preparent, postparent, xdata):
|
||||
unique = dl.get_rootunique(frame)
|
||||
key = dl.get_id(frame)
|
||||
gfid = self.gfids[key]
|
||||
if op_ret == 0:
|
||||
statstr = trace_stat2str(buf)
|
||||
preparentstr = trace_stat2str(preparent)
|
||||
postparentstr = trace_stat2str(postparent)
|
||||
print("GLUPY TRACE SYMLINK CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; *stbuf={3:s}; *preparent={4:s}; "+
|
||||
"*postparent={5:s}").format(unique, gfid,
|
||||
op_ret, statstr,
|
||||
preparentstr,
|
||||
postparentstr)
|
||||
else:
|
||||
print("GLUPY TRACE SYMLINK CBK- {0:d}: gfid={1:s}; "+
|
||||
"op_ret={2:d}; op_errno={3:d}").format(unique,
|
||||
gfid,
|
||||
op_ret,
|
||||
op_errno)
|
||||
del self.gfids[key]
|
||||
dl.unwind_symlink(frame, cookie, this, op_ret, op_errno,
|
||||
inode, buf, preparent, postparent, xdata)
|
||||
return 0
|
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,28 @@
|
||||
enum {
|
||||
GLUPY_LOOKUP = 0,
|
||||
GLUPY_CREATE,
|
||||
GLUPY_OPEN,
|
||||
GLUPY_READV,
|
||||
GLUPY_WRITEV,
|
||||
GLUPY_OPENDIR,
|
||||
GLUPY_READDIR,
|
||||
GLUPY_READDIRP,
|
||||
GLUPY_STAT,
|
||||
GLUPY_FSTAT,
|
||||
GLUPY_STATFS,
|
||||
GLUPY_SETXATTR,
|
||||
GLUPY_GETXATTR,
|
||||
GLUPY_FSETXATTR,
|
||||
GLUPY_FGETXATTR,
|
||||
GLUPY_REMOVEXATTR,
|
||||
GLUPY_FREMOVEXATTR,
|
||||
GLUPY_LINK,
|
||||
GLUPY_UNLINK,
|
||||
GLUPY_READLINK,
|
||||
GLUPY_SYMLINK,
|
||||
GLUPY_MKNOD,
|
||||
GLUPY_MKDIR,
|
||||
GLUPY_RMDIR,
|
||||
GLUPY_N_FUNCS
|
||||
};
|
||||
|
||||
|
@ -3,116 +3,839 @@ from ctypes import *
|
||||
|
||||
dl = CDLL("",RTLD_GLOBAL)
|
||||
|
||||
|
||||
class call_frame_t (Structure):
|
||||
pass
|
||||
pass
|
||||
|
||||
class dev_t (Structure):
|
||||
pass
|
||||
|
||||
|
||||
class dict_t (Structure):
|
||||
pass
|
||||
|
||||
|
||||
class gf_dirent_t (Structure):
|
||||
pass
|
||||
|
||||
|
||||
class iobref_t (Structure):
|
||||
pass
|
||||
|
||||
class fd_t (Structure):
|
||||
pass
|
||||
|
||||
class iatt_t (Structure):
|
||||
pass
|
||||
class iovec_t (Structure):
|
||||
pass
|
||||
|
||||
class inode_t (Structure):
|
||||
pass
|
||||
|
||||
class loc_t (Structure):
|
||||
_fields_ = [
|
||||
( "path", c_char_p ),
|
||||
( "name", c_char_p ),
|
||||
( "inode", c_void_p ),
|
||||
( "parent", c_void_p ),
|
||||
# Not quite correct, but easier to manipulate.
|
||||
( "gfid", c_uint * 4 ),
|
||||
( "pargfid", c_uint * 4 ),
|
||||
]
|
||||
class list_head (Structure):
|
||||
pass
|
||||
|
||||
list_head._fields_ = [
|
||||
("next", POINTER(list_head)),
|
||||
("prev", POINTER(list_head))
|
||||
]
|
||||
|
||||
|
||||
class rwxperm_t (Structure):
|
||||
_fields_ = [
|
||||
("read", c_uint8, 1),
|
||||
("write", c_uint8, 1),
|
||||
("execn", c_uint8, 1)
|
||||
]
|
||||
|
||||
|
||||
class statvfs_t (Structure):
|
||||
pass
|
||||
|
||||
|
||||
class xlator_t (Structure):
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
class ia_prot_t (Structure):
|
||||
_fields_ = [
|
||||
("suid", c_uint8, 1),
|
||||
("sgid", c_uint8, 1),
|
||||
("sticky", c_uint8, 1),
|
||||
("owner", rwxperm_t),
|
||||
("group", rwxperm_t),
|
||||
("other", rwxperm_t)
|
||||
]
|
||||
|
||||
# For checking file type.
|
||||
(IA_INVAL, IA_IFREG, IA_IFDIR, IA_IFLNK, IA_IFBLK, IA_IFCHR, IA_IFIFO,
|
||||
IA_IFSOCK) = xrange(8)
|
||||
|
||||
|
||||
class iatt_t (Structure):
|
||||
_fields_ = [
|
||||
("ia_no", c_uint64),
|
||||
("ia_gfid", c_ubyte * 16),
|
||||
("ia_dev", c_uint64),
|
||||
("ia_type", c_uint),
|
||||
("ia_prot", ia_prot_t),
|
||||
("ia_nlink", c_uint32),
|
||||
("ia_uid", c_uint32),
|
||||
("ia_gid", c_uint32),
|
||||
("ia_rdev", c_uint64),
|
||||
("ia_size", c_uint64),
|
||||
("ia_blksize", c_uint32),
|
||||
("ia_blocks", c_uint64),
|
||||
("ia_atime", c_uint32 ),
|
||||
("ia_atime_nsec", c_uint32),
|
||||
("ia_mtime", c_uint32),
|
||||
("ia_mtime_nsec", c_uint32),
|
||||
("ia_ctime", c_uint32),
|
||||
("ia_ctime_nsec", c_uint32)
|
||||
]
|
||||
|
||||
|
||||
class mem_pool (Structure):
|
||||
_fields_ = [
|
||||
("list", list_head),
|
||||
("hot_count", c_int),
|
||||
("cold_count", c_int),
|
||||
("lock", c_void_p),
|
||||
("padded_sizeof_type", c_ulong),
|
||||
("pool", c_void_p),
|
||||
("pool_end", c_void_p),
|
||||
("real_sizeof_type", c_int),
|
||||
("alloc_count", c_uint64),
|
||||
("pool_misses", c_uint64),
|
||||
("max_alloc", c_int),
|
||||
("curr_stdalloc", c_int),
|
||||
("max_stdalloc", c_int),
|
||||
("name", c_char_p),
|
||||
("global_list", list_head)
|
||||
]
|
||||
|
||||
|
||||
class U_ctx_key_inode (Union):
|
||||
_fields_ = [
|
||||
("key", c_uint64),
|
||||
("xl_key", POINTER(xlator_t))
|
||||
]
|
||||
|
||||
|
||||
class U_ctx_value1 (Union):
|
||||
_fields_ = [
|
||||
("value1", c_uint64),
|
||||
("ptr1", c_void_p)
|
||||
]
|
||||
|
||||
|
||||
class U_ctx_value2 (Union):
|
||||
_fields_ = [
|
||||
("value2", c_uint64),
|
||||
("ptr2", c_void_p)
|
||||
]
|
||||
|
||||
class inode_ctx (Structure):
|
||||
_anonymous_ = ("u_key","u_value1","u_value2",)
|
||||
_fields_ = [
|
||||
("u_key", U_ctx_key_inode),
|
||||
("u_value1", U_ctx_value1),
|
||||
("u_value2", U_ctx_value2)
|
||||
]
|
||||
|
||||
class inode_t (Structure):
|
||||
pass
|
||||
|
||||
class inode_table_t (Structure):
|
||||
_fields_ = [
|
||||
("lock", c_void_p),
|
||||
("hashsize", c_size_t),
|
||||
("name", c_char_p),
|
||||
("root", POINTER(inode_t)),
|
||||
("xl", POINTER(xlator_t)),
|
||||
("lru_limit", c_uint32),
|
||||
("inode_hash", POINTER(list_head)),
|
||||
("name_hash", POINTER(list_head)),
|
||||
("active", list_head),
|
||||
("active_size", c_uint32),
|
||||
("lru", list_head),
|
||||
("lru_size", c_uint32),
|
||||
("purge", list_head),
|
||||
("purge_size", c_uint32),
|
||||
("inode_pool", POINTER(mem_pool)),
|
||||
("dentry_pool", POINTER(mem_pool)),
|
||||
("fd_mem_pool", POINTER(mem_pool))
|
||||
]
|
||||
|
||||
inode_t._fields_ = [
|
||||
("table", POINTER(inode_table_t)),
|
||||
("gfid", c_ubyte * 16),
|
||||
("lock", c_void_p),
|
||||
("nlookup", c_uint64),
|
||||
("fd_count", c_uint32),
|
||||
("ref", c_uint32),
|
||||
("ia_type", c_uint),
|
||||
("fd_list", list_head),
|
||||
("dentry_list", list_head),
|
||||
("hashv", list_head),
|
||||
("listv", list_head),
|
||||
("ctx", POINTER(inode_ctx))
|
||||
]
|
||||
|
||||
|
||||
|
||||
class U_ctx_key_fd (Union):
|
||||
_fields_ = [
|
||||
("key", c_uint64),
|
||||
("xl_key", c_void_p)
|
||||
]
|
||||
|
||||
class fd_lk_ctx (Structure):
|
||||
_fields_ = [
|
||||
("lk_list", list_head),
|
||||
("ref", c_int),
|
||||
("lock", c_void_p)
|
||||
]
|
||||
|
||||
class fd_ctx (Structure):
|
||||
_anonymous_ = ("u_key","u_value1")
|
||||
_fields_ = [
|
||||
("u_key", U_ctx_key_fd),
|
||||
("u_value1", U_ctx_value1)
|
||||
]
|
||||
|
||||
class fd_t (Structure):
|
||||
_fields_ = [
|
||||
("pid", c_uint64),
|
||||
("flags", c_int32),
|
||||
("refcount", c_int32),
|
||||
("inode_list", list_head),
|
||||
("inode", POINTER(inode_t)),
|
||||
("lock", c_void_p),
|
||||
("ctx", POINTER(fd_ctx)),
|
||||
("xl_count", c_int),
|
||||
("lk_ctx", POINTER(fd_lk_ctx)),
|
||||
("anonymous", c_uint)
|
||||
]
|
||||
|
||||
class loc_t (Structure):
|
||||
_fields_ = [
|
||||
("path", c_char_p),
|
||||
("name", c_char_p),
|
||||
("inode", POINTER(inode_t)),
|
||||
("parent", POINTER(inode_t)),
|
||||
("gfid", c_ubyte * 16),
|
||||
("pargfid", c_ubyte * 16),
|
||||
]
|
||||
|
||||
|
||||
|
||||
def _init_op (a_class, fop, cbk, wind, unwind):
|
||||
# Decorators, used by translators. We could pass the signatures as
|
||||
# parameters, but it's actually kind of nice to keep them around for
|
||||
# inspection.
|
||||
a_class.fop_type = apply(CFUNCTYPE,a_class.fop_sig)
|
||||
a_class.cbk_type = apply(CFUNCTYPE,a_class.cbk_sig)
|
||||
# Dispatch-function registration.
|
||||
fop.restype = None
|
||||
fop.argtypes = [ c_long, a_class.fop_type ]
|
||||
# Callback-function registration.
|
||||
cbk.restype = None
|
||||
cbk.argtypes = [ c_long, a_class.cbk_type ]
|
||||
# STACK_WIND function.
|
||||
wind.restype = None
|
||||
wind.argtypes = list(a_class.fop_sig[1:])
|
||||
# STACK_UNWIND function.
|
||||
unwind.restype = None
|
||||
unwind.argtypes = list(a_class.cbk_sig[1:])
|
||||
# Decorators, used by translators. We could pass the signatures as
|
||||
# parameters, but it's actually kind of nice to keep them around for
|
||||
# inspection.
|
||||
a_class.fop_type = apply(CFUNCTYPE,a_class.fop_sig)
|
||||
a_class.cbk_type = apply(CFUNCTYPE,a_class.cbk_sig)
|
||||
# Dispatch-function registration.
|
||||
fop.restype = None
|
||||
fop.argtypes = [ c_long, a_class.fop_type ]
|
||||
# Callback-function registration.
|
||||
cbk.restype = None
|
||||
cbk.argtypes = [ c_long, a_class.cbk_type ]
|
||||
# STACK_WIND function.
|
||||
wind.restype = None
|
||||
wind.argtypes = list(a_class.fop_sig[1:])
|
||||
# STACK_UNWIND function.
|
||||
unwind.restype = None
|
||||
unwind.argtypes = list(a_class.cbk_sig[1:])
|
||||
|
||||
class OpLookup:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(inode_t), POINTER(iatt_t),
|
||||
POINTER(dict_t), POINTER(iatt_t))
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(inode_t), POINTER(iatt_t),
|
||||
POINTER(dict_t), POINTER(iatt_t))
|
||||
_init_op (OpLookup, dl.set_lookup_fop, dl.set_lookup_cbk,
|
||||
dl.wind_lookup, dl.unwind_lookup)
|
||||
dl.wind_lookup, dl.unwind_lookup)
|
||||
|
||||
class OpCreate:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), c_int, c_uint, c_uint, POINTER(fd_t),
|
||||
POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(fd_t), POINTER(inode_t),
|
||||
POINTER(iatt_t), POINTER(iatt_t), POINTER(iatt_t),
|
||||
POINTER(dict_t))
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), c_int, c_uint, c_uint, POINTER(fd_t),
|
||||
POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(fd_t), POINTER(inode_t),
|
||||
POINTER(iatt_t), POINTER(iatt_t), POINTER(iatt_t),
|
||||
POINTER(dict_t))
|
||||
_init_op (OpCreate, dl.set_create_fop, dl.set_create_cbk,
|
||||
dl.wind_create, dl.unwind_create)
|
||||
dl.wind_create, dl.unwind_create)
|
||||
|
||||
class OpOpen:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), c_int, POINTER(fd_t), POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(fd_t), POINTER(dict_t))
|
||||
_init_op (OpOpen, dl.set_open_fop, dl.set_open_cbk,
|
||||
dl.wind_open, dl.unwind_open)
|
||||
|
||||
class OpReadv:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(fd_t), c_size_t, c_long, c_uint32, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(iovec_t), c_int, POINTER(iatt_t),
|
||||
POINTER(iobref_t), POINTER(dict_t))
|
||||
_init_op (OpReadv, dl.set_readv_fop, dl.set_readv_cbk,
|
||||
dl.wind_readv, dl.unwind_readv)
|
||||
class OpWritev:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(fd_t), POINTER(iovec_t), c_int, c_long, c_uint32,
|
||||
POINTER(iobref_t), POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(iatt_t), POINTER(iatt_t),
|
||||
POINTER(dict_t))
|
||||
_init_op (OpWritev, dl.set_writev_fop, dl.set_writev_cbk,
|
||||
dl.wind_writev, dl.unwind_writev)
|
||||
|
||||
class OpOpendir:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), POINTER(fd_t) ,POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(fd_t), POINTER(dict_t))
|
||||
_init_op (OpOpendir, dl.set_opendir_fop, dl.set_opendir_cbk,
|
||||
dl.wind_opendir, dl.unwind_opendir)
|
||||
|
||||
class OpReaddir:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(fd_t), c_size_t, c_long, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(gf_dirent_t), POINTER(dict_t))
|
||||
_init_op (OpReaddir, dl.set_readdir_fop, dl.set_readdir_cbk,
|
||||
dl.wind_readdir, dl.unwind_readdir)
|
||||
|
||||
class OpReaddirp:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(fd_t), c_size_t, c_long, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(gf_dirent_t), POINTER(dict_t))
|
||||
_init_op (OpReaddirp, dl.set_readdirp_fop, dl.set_readdirp_cbk,
|
||||
dl.wind_readdirp, dl.unwind_readdirp)
|
||||
|
||||
class OpStat:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(iatt_t), POINTER(dict_t))
|
||||
_init_op (OpStat, dl.set_stat_fop, dl.set_stat_cbk,
|
||||
dl.wind_stat, dl.unwind_stat)
|
||||
|
||||
class OpFstat:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(fd_t), POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(iatt_t), POINTER(dict_t))
|
||||
_init_op (OpFstat, dl.set_fstat_fop, dl.set_fstat_cbk,
|
||||
dl.wind_fstat, dl.unwind_fstat)
|
||||
|
||||
class OpStatfs:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(statvfs_t), POINTER(dict_t))
|
||||
_init_op (OpStatfs, dl.set_statfs_fop, dl.set_statfs_cbk,
|
||||
dl.wind_statfs, dl.unwind_statfs)
|
||||
|
||||
|
||||
class OpSetxattr:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), POINTER(dict_t), c_int32,
|
||||
POINTER (dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(dict_t))
|
||||
_init_op (OpSetxattr, dl.set_setxattr_fop, dl.set_setxattr_cbk,
|
||||
dl.wind_setxattr, dl.unwind_setxattr)
|
||||
|
||||
class OpGetxattr:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), c_char_p, POINTER (dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(dict_t), POINTER(dict_t))
|
||||
_init_op (OpGetxattr, dl.set_getxattr_fop, dl.set_getxattr_cbk,
|
||||
dl.wind_getxattr, dl.unwind_getxattr)
|
||||
|
||||
class OpFsetxattr:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(fd_t), POINTER(dict_t), c_int32,
|
||||
POINTER (dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(dict_t))
|
||||
_init_op (OpFsetxattr, dl.set_fsetxattr_fop, dl.set_fsetxattr_cbk,
|
||||
dl.wind_fsetxattr, dl.unwind_fsetxattr)
|
||||
|
||||
class OpFgetxattr:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(fd_t), c_char_p, POINTER (dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(dict_t), POINTER(dict_t))
|
||||
_init_op (OpFgetxattr, dl.set_fgetxattr_fop, dl.set_fgetxattr_cbk,
|
||||
dl.wind_fgetxattr, dl.unwind_fgetxattr)
|
||||
|
||||
class OpRemovexattr:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), c_char_p, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(dict_t))
|
||||
_init_op (OpRemovexattr, dl.set_removexattr_fop, dl.set_removexattr_cbk,
|
||||
dl.wind_removexattr, dl.unwind_removexattr)
|
||||
|
||||
|
||||
class OpFremovexattr:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(fd_t), c_char_p, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(dict_t))
|
||||
_init_op (OpFremovexattr, dl.set_fremovexattr_fop, dl.set_fremovexattr_cbk,
|
||||
dl.wind_fremovexattr, dl.unwind_fremovexattr)
|
||||
|
||||
class OpLink:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), POINTER(loc_t), POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(inode_t), POINTER(iatt_t),
|
||||
POINTER(iatt_t), POINTER(iatt_t), POINTER(dict_t))
|
||||
_init_op (OpLink, dl.set_link_fop, dl.set_link_cbk,
|
||||
dl.wind_link, dl.unwind_link)
|
||||
|
||||
class OpSymlink:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
c_char_p, POINTER(loc_t), c_uint, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(inode_t), POINTER(iatt_t),
|
||||
POINTER(iatt_t), POINTER(iatt_t), POINTER(dict_t))
|
||||
_init_op (OpSymlink, dl.set_symlink_fop, dl.set_symlink_cbk,
|
||||
dl.wind_symlink, dl.unwind_symlink)
|
||||
|
||||
class OpUnlink:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), c_int, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(iatt_t), POINTER(iatt_t),
|
||||
POINTER(dict_t))
|
||||
_init_op (OpUnlink, dl.set_unlink_fop, dl.set_unlink_cbk,
|
||||
dl.wind_unlink, dl.unwind_unlink)
|
||||
|
||||
class OpReadlink:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), c_size_t, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, c_char_p, POINTER(iatt_t), POINTER(dict_t))
|
||||
_init_op (OpReadlink, dl.set_readlink_fop, dl.set_readlink_cbk,
|
||||
dl.wind_readlink, dl.unwind_readlink)
|
||||
|
||||
class OpMkdir:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), c_uint, c_uint, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(inode_t), POINTER(iatt_t),
|
||||
POINTER(iatt_t), POINTER(iatt_t), POINTER(dict_t))
|
||||
_init_op (OpMkdir, dl.set_mkdir_fop, dl.set_mkdir_cbk,
|
||||
dl.wind_mkdir, dl.unwind_mkdir)
|
||||
|
||||
class OpRmdir:
|
||||
fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t),
|
||||
POINTER(loc_t), c_int, POINTER(dict_t))
|
||||
cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t),
|
||||
c_int, c_int, POINTER(iatt_t), POINTER(iatt_t),
|
||||
POINTER(dict_t))
|
||||
_init_op (OpRmdir, dl.set_rmdir_fop, dl.set_rmdir_cbk,
|
||||
dl.wind_rmdir, dl.unwind_rmdir)
|
||||
|
||||
|
||||
class Translator:
|
||||
def __init__ (self, c_this):
|
||||
# This is only here to keep references to the stubs we create,
|
||||
# because ctypes doesn't and glupy.so can't because it doesn't
|
||||
# get a pointer to the actual Python object. It's a dictionary
|
||||
# instead of a list in case we ever allow changing fops/cbks
|
||||
# after initialization and need to look them up.
|
||||
self.stub_refs = {}
|
||||
funcs = dir(self.__class__)
|
||||
if "lookup_fop" in funcs:
|
||||
@OpLookup.fop_type
|
||||
def stub (frame, this, loc, xdata, s=self):
|
||||
return s.lookup_fop (frame, this, loc, xdata)
|
||||
self.stub_refs["lookup_fop"] = stub
|
||||
dl.set_lookup_fop(c_this,stub)
|
||||
if "lookup_cbk" in funcs:
|
||||
@OpLookup.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, inode,
|
||||
buf, xdata, postparent, s=self):
|
||||
return s.lookup_cbk(frame, cookie, this, op_ret,
|
||||
op_errno, inode, buf, xdata,
|
||||
postparent)
|
||||
self.stub_refs["lookup_cbk"] = stub
|
||||
dl.set_lookup_cbk(c_this,stub)
|
||||
if "create_fop" in funcs:
|
||||
@OpCreate.fop_type
|
||||
def stub (frame, this, loc, flags, mode, umask, fd,
|
||||
xdata, s=self):
|
||||
return s.create_fop (frame, this, loc, flags,
|
||||
mode, umask, fd, xdata)
|
||||
self.stub_refs["create_fop"] = stub
|
||||
dl.set_create_fop(c_this,stub)
|
||||
if "create_cbk" in funcs:
|
||||
@OpCreate.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, fd,
|
||||
inode, buf, preparent, postparent, xdata,
|
||||
s=self):
|
||||
return s.create_cbk (frame, cookie, this,
|
||||
op_ret, op_errno, fd,
|
||||
inode, buf, preparent,
|
||||
postparent, xdata)
|
||||
return 0
|
||||
self.stub_refs["create_cbk"] = stub
|
||||
dl.set_create_cbk(c_this,stub)
|
||||
|
||||
def __init__ (self, c_this):
|
||||
# This is only here to keep references to the stubs we create,
|
||||
# because ctypes doesn't and glupy.so can't because it doesn't
|
||||
# get a pointer to the actual Python object. It's a dictionary
|
||||
# instead of a list in case we ever allow changing fops/cbks
|
||||
# after initialization and need to look them up.
|
||||
self.stub_refs = {}
|
||||
funcs = dir(self.__class__)
|
||||
if "lookup_fop" in funcs:
|
||||
@OpLookup.fop_type
|
||||
def stub (frame, this, loc, xdata, s=self):
|
||||
return s.lookup_fop (frame, this, loc, xdata)
|
||||
self.stub_refs["lookup_fop"] = stub
|
||||
dl.set_lookup_fop(c_this,stub)
|
||||
if "lookup_cbk" in funcs:
|
||||
@OpLookup.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, inode,
|
||||
buf, xdata, postparent, s=self):
|
||||
return s.lookup_cbk(frame, cookie, this, op_ret,
|
||||
op_errno, inode, buf, xdata,
|
||||
postparent)
|
||||
self.stub_refs["lookup_cbk"] = stub
|
||||
dl.set_lookup_cbk(c_this,stub)
|
||||
if "create_fop" in funcs:
|
||||
@OpCreate.fop_type
|
||||
def stub (frame, this, loc, flags, mode, umask, fd,
|
||||
xdata, s=self):
|
||||
return s.create_fop (frame, this, loc, flags,
|
||||
mode, umask, fd, xdata)
|
||||
self.stub_refs["create_fop"] = stub
|
||||
dl.set_create_fop(c_this,stub)
|
||||
if "create_cbk" in funcs:
|
||||
@OpCreate.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, fd,
|
||||
inode, buf, preparent, postparent, xdata,
|
||||
s=self):
|
||||
return s.create_cbk (frame, cookie, this,
|
||||
op_ret, op_errno, fd,
|
||||
inode, buf, preparent,
|
||||
postparent, xdata)
|
||||
self.stub_refs["create_cbk"] = stub
|
||||
dl.set_create_cbk(c_this,stub)
|
||||
if "open_fop" in funcs:
|
||||
@OpOpen.fop_type
|
||||
def stub (frame, this, loc, flags, fd,
|
||||
xdata, s=self):
|
||||
return s.open_fop (frame, this, loc, flags,
|
||||
fd, xdata)
|
||||
self.stub_refs["open_fop"] = stub
|
||||
dl.set_open_fop(c_this,stub)
|
||||
if "open_cbk" in funcs:
|
||||
@OpOpen.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, fd,
|
||||
xdata, s=self):
|
||||
return s.open_cbk (frame, cookie, this,
|
||||
op_ret, op_errno, fd,
|
||||
xdata)
|
||||
self.stub_refs["open_cbk"] = stub
|
||||
dl.set_open_cbk(c_this,stub)
|
||||
if "readv_fop" in funcs:
|
||||
@OpReadv.fop_type
|
||||
def stub (frame, this, fd, size, offset, flags,
|
||||
xdata, s=self):
|
||||
return s.readv_fop (frame, this, fd, size,
|
||||
offset, flags, xdata)
|
||||
self.stub_refs["readv_fop"] = stub
|
||||
dl.set_readv_fop(c_this,stub)
|
||||
if "readv_cbk" in funcs:
|
||||
@OpReadv.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
vector, count, stbuf, iobref, xdata,
|
||||
s=self):
|
||||
return s.readv_cbk (frame, cookie, this,
|
||||
op_ret, op_errno, vector,
|
||||
count, stbuf, iobref,
|
||||
xdata)
|
||||
self.stub_refs["readv_cbk"] = stub
|
||||
dl.set_readv_cbk(c_this,stub)
|
||||
if "writev_fop" in funcs:
|
||||
@OpWritev.fop_type
|
||||
def stub (frame, this, fd, vector, count,
|
||||
offset, flags, iobref, xdata, s=self):
|
||||
return s.writev_fop (frame, this, fd, vector,
|
||||
count, offset, flags,
|
||||
iobref, xdata)
|
||||
self.stub_refs["writev_fop"] = stub
|
||||
dl.set_writev_fop(c_this,stub)
|
||||
if "writev_cbk" in funcs:
|
||||
@OpWritev.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
prebuf, postbuf, xdata, s=self):
|
||||
return s.writev_cbk (frame, cookie, this,
|
||||
op_ret, op_errno, prebuf,
|
||||
postbuf, xdata)
|
||||
self.stub_refs["writev_cbk"] = stub
|
||||
dl.set_writev_cbk(c_this,stub)
|
||||
if "opendir_fop" in funcs:
|
||||
@OpOpendir.fop_type
|
||||
def stub (frame, this, loc, fd, xdata, s=self):
|
||||
return s.opendir_fop (frame, this, loc, fd,
|
||||
xdata)
|
||||
self.stub_refs["opendir_fop"] = stub
|
||||
dl.set_opendir_fop(c_this,stub)
|
||||
if "opendir_cbk" in funcs:
|
||||
@OpOpendir.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, fd,
|
||||
xdata, s=self):
|
||||
return s.opendir_cbk(frame, cookie, this,
|
||||
op_ret, op_errno, fd,
|
||||
xdata)
|
||||
self.stub_refs["opendir_cbk"] = stub
|
||||
dl.set_opendir_cbk(c_this,stub)
|
||||
if "readdir_fop" in funcs:
|
||||
@OpReaddir.fop_type
|
||||
def stub (frame, this, fd, size, offset, xdata, s=self):
|
||||
return s.readdir_fop (frame, this, fd, size,
|
||||
offset, xdata)
|
||||
self.stub_refs["readdir_fop"] = stub
|
||||
dl.set_readdir_fop(c_this,stub)
|
||||
if "readdir_cbk" in funcs:
|
||||
@OpReaddir.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
entries, xdata, s=self):
|
||||
return s.readdir_cbk(frame, cookie, this,
|
||||
op_ret, op_errno, entries,
|
||||
xdata)
|
||||
self.stub_refs["readdir_cbk"] = stub
|
||||
dl.set_readdir_cbk(c_this,stub)
|
||||
if "readdirp_fop" in funcs:
|
||||
@OpReaddirp.fop_type
|
||||
def stub (frame, this, fd, size, offset, xdata, s=self):
|
||||
return s.readdirp_fop (frame, this, fd, size,
|
||||
offset, xdata)
|
||||
self.stub_refs["readdirp_fop"] = stub
|
||||
dl.set_readdirp_fop(c_this,stub)
|
||||
if "readdirp_cbk" in funcs:
|
||||
@OpReaddirp.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
entries, xdata, s=self):
|
||||
return s.readdirp_cbk (frame, cookie, this,
|
||||
op_ret, op_errno,
|
||||
entries, xdata)
|
||||
self.stub_refs["readdirp_cbk"] = stub
|
||||
dl.set_readdirp_cbk(c_this,stub)
|
||||
if "stat_fop" in funcs:
|
||||
@OpStat.fop_type
|
||||
def stub (frame, this, loc, xdata, s=self):
|
||||
return s.stat_fop (frame, this, loc, xdata)
|
||||
self.stub_refs["stat_fop"] = stub
|
||||
dl.set_stat_fop(c_this,stub)
|
||||
if "stat_cbk" in funcs:
|
||||
@OpStat.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata, s=self):
|
||||
return s.stat_cbk(frame, cookie, this, op_ret,
|
||||
op_errno, buf, xdata)
|
||||
self.stub_refs["stat_cbk"] = stub
|
||||
dl.set_stat_cbk(c_this,stub)
|
||||
if "fstat_fop" in funcs:
|
||||
@OpFstat.fop_type
|
||||
def stub (frame, this, fd, xdata, s=self):
|
||||
return s.fstat_fop (frame, this, fd, xdata)
|
||||
self.stub_refs["fstat_fop"] = stub
|
||||
dl.set_fstat_fop(c_this,stub)
|
||||
if "fstat_cbk" in funcs:
|
||||
@OpFstat.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata, s=self):
|
||||
return s.fstat_cbk(frame, cookie, this, op_ret,
|
||||
op_errno, buf, xdata)
|
||||
self.stub_refs["fstat_cbk"] = stub
|
||||
dl.set_fstat_cbk(c_this,stub)
|
||||
if "statfs_fop" in funcs:
|
||||
@OpStatfs.fop_type
|
||||
def stub (frame, this, loc, xdata, s=self):
|
||||
return s.statfs_fop (frame, this, loc, xdata)
|
||||
self.stub_refs["statfs_fop"] = stub
|
||||
dl.set_statfs_fop(c_this,stub)
|
||||
if "statfs_cbk" in funcs:
|
||||
@OpStatfs.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, buf,
|
||||
xdata, s=self):
|
||||
return s.statfs_cbk (frame, cookie, this,
|
||||
op_ret, op_errno, buf,
|
||||
xdata)
|
||||
self.stub_refs["statfs_cbk"] = stub
|
||||
dl.set_statfs_cbk(c_this,stub)
|
||||
if "setxattr_fop" in funcs:
|
||||
@OpSetxattr.fop_type
|
||||
def stub (frame, this, loc, dictionary, flags, xdata,
|
||||
s=self):
|
||||
return s.setxattr_fop (frame, this, loc,
|
||||
dictionary, flags,
|
||||
xdata)
|
||||
self.stub_refs["setxattr_fop"] = stub
|
||||
dl.set_setxattr_fop(c_this,stub)
|
||||
if "setxattr_cbk" in funcs:
|
||||
@OpSetxattr.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, xdata,
|
||||
s=self):
|
||||
return s.setxattr_cbk(frame, cookie, this,
|
||||
op_ret, op_errno, xdata)
|
||||
self.stub_refs["setxattr_cbk"] = stub
|
||||
dl.set_setxattr_cbk(c_this,stub)
|
||||
if "getxattr_fop" in funcs:
|
||||
@OpGetxattr.fop_type
|
||||
def stub (frame, this, loc, name, xdata, s=self):
|
||||
return s.getxattr_fop (frame, this, loc, name,
|
||||
xdata)
|
||||
self.stub_refs["getxattr_fop"] = stub
|
||||
dl.set_getxattr_fop(c_this,stub)
|
||||
if "getxattr_cbk" in funcs:
|
||||
@OpGetxattr.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
dictionary, xdata, s=self):
|
||||
return s.getxattr_cbk(frame, cookie, this,
|
||||
op_ret, op_errno,
|
||||
dictionary, xdata)
|
||||
self.stub_refs["getxattr_cbk"] = stub
|
||||
dl.set_getxattr_cbk(c_this,stub)
|
||||
if "fsetxattr_fop" in funcs:
|
||||
@OpFsetxattr.fop_type
|
||||
def stub (frame, this, fd, dictionary, flags, xdata,
|
||||
s=self):
|
||||
return s.fsetxattr_fop (frame, this, fd,
|
||||
dictionary, flags,
|
||||
xdata)
|
||||
self.stub_refs["fsetxattr_fop"] = stub
|
||||
dl.set_fsetxattr_fop(c_this,stub)
|
||||
if "fsetxattr_cbk" in funcs:
|
||||
@OpFsetxattr.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, xdata,
|
||||
s=self):
|
||||
return s.fsetxattr_cbk(frame, cookie, this,
|
||||
op_ret, op_errno, xdata)
|
||||
self.stub_refs["fsetxattr_cbk"] = stub
|
||||
dl.set_fsetxattr_cbk(c_this,stub)
|
||||
if "fgetxattr_fop" in funcs:
|
||||
@OpFgetxattr.fop_type
|
||||
def stub (frame, this, fd, name, xdata, s=self):
|
||||
return s.fgetxattr_fop (frame, this, fd, name,
|
||||
xdata)
|
||||
self.stub_refs["fgetxattr_fop"] = stub
|
||||
dl.set_fgetxattr_fop(c_this,stub)
|
||||
if "fgetxattr_cbk" in funcs:
|
||||
@OpFgetxattr.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
dictionary, xdata, s=self):
|
||||
return s.fgetxattr_cbk(frame, cookie, this,
|
||||
op_ret, op_errno,
|
||||
dictionary, xdata)
|
||||
self.stub_refs["fgetxattr_cbk"] = stub
|
||||
dl.set_fgetxattr_cbk(c_this,stub)
|
||||
if "removexattr_fop" in funcs:
|
||||
@OpRemovexattr.fop_type
|
||||
def stub (frame, this, loc, name, xdata, s=self):
|
||||
return s.removexattr_fop (frame, this, loc,
|
||||
name, xdata)
|
||||
self.stub_refs["removexattr_fop"] = stub
|
||||
dl.set_removexattr_fop(c_this,stub)
|
||||
if "removexattr_cbk" in funcs:
|
||||
@OpRemovexattr.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
xdata, s=self):
|
||||
return s.removexattr_cbk(frame, cookie, this,
|
||||
op_ret, op_errno,
|
||||
xdata)
|
||||
self.stub_refs["removexattr_cbk"] = stub
|
||||
dl.set_removexattr_cbk(c_this,stub)
|
||||
if "fremovexattr_fop" in funcs:
|
||||
@OpFremovexattr.fop_type
|
||||
def stub (frame, this, fd, name, xdata, s=self):
|
||||
return s.fremovexattr_fop (frame, this, fd,
|
||||
name, xdata)
|
||||
self.stub_refs["fremovexattr_fop"] = stub
|
||||
dl.set_fremovexattr_fop(c_this,stub)
|
||||
if "fremovexattr_cbk" in funcs:
|
||||
@OpFremovexattr.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
xdata, s=self):
|
||||
return s.fremovexattr_cbk(frame, cookie, this,
|
||||
op_ret, op_errno,
|
||||
xdata)
|
||||
self.stub_refs["fremovexattr_cbk"] = stub
|
||||
dl.set_fremovexattr_cbk(c_this,stub)
|
||||
if "link_fop" in funcs:
|
||||
@OpLink.fop_type
|
||||
def stub (frame, this, oldloc, newloc,
|
||||
xdata, s=self):
|
||||
return s.link_fop (frame, this, oldloc,
|
||||
newloc, xdata)
|
||||
self.stub_refs["link_fop"] = stub
|
||||
dl.set_link_fop(c_this,stub)
|
||||
if "link_cbk" in funcs:
|
||||
@OpLink.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
inode, buf, preparent, postparent, xdata,
|
||||
s=self):
|
||||
return s.link_cbk (frame, cookie, this,
|
||||
op_ret, op_errno, inode,
|
||||
buf, preparent,
|
||||
postparent, xdata)
|
||||
self.stub_refs["link_cbk"] = stub
|
||||
dl.set_link_cbk(c_this,stub)
|
||||
if "symlink_fop" in funcs:
|
||||
@OpSymlink.fop_type
|
||||
def stub (frame, this, linkname, loc,
|
||||
umask, xdata, s=self):
|
||||
return s.symlink_fop (frame, this, linkname,
|
||||
loc, umask, xdata)
|
||||
self.stub_refs["symlink_fop"] = stub
|
||||
dl.set_symlink_fop(c_this,stub)
|
||||
if "symlink_cbk" in funcs:
|
||||
@OpSymlink.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
inode, buf, preparent, postparent, xdata,
|
||||
s=self):
|
||||
return s.symlink_cbk (frame, cookie, this,
|
||||
op_ret, op_errno, inode,
|
||||
buf, preparent,
|
||||
postparent, xdata)
|
||||
self.stub_refs["symlink_cbk"] = stub
|
||||
dl.set_symlink_cbk(c_this,stub)
|
||||
if "unlink_fop" in funcs:
|
||||
@OpUnlink.fop_type
|
||||
def stub (frame, this, loc, xflags,
|
||||
xdata, s=self):
|
||||
return s.unlink_fop (frame, this, loc,
|
||||
xflags, xdata)
|
||||
self.stub_refs["unlink_fop"] = stub
|
||||
dl.set_unlink_fop(c_this,stub)
|
||||
if "unlink_cbk" in funcs:
|
||||
@OpUnlink.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
preparent, postparent, xdata, s=self):
|
||||
return s.unlink_cbk (frame, cookie, this,
|
||||
op_ret, op_errno,
|
||||
preparent, postparent,
|
||||
xdata)
|
||||
self.stub_refs["unlink_cbk"] = stub
|
||||
dl.set_unlink_cbk(c_this,stub)
|
||||
if "readlink_fop" in funcs:
|
||||
@OpReadlink.fop_type
|
||||
def stub (frame, this, loc, size,
|
||||
xdata, s=self):
|
||||
return s.readlink_fop (frame, this, loc,
|
||||
size, xdata)
|
||||
self.stub_refs["readlink_fop"] = stub
|
||||
dl.set_readlink_fop(c_this,stub)
|
||||
if "readlink_cbk" in funcs:
|
||||
@OpReadlink.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
path, buf, xdata, s=self):
|
||||
return s.readlink_cbk (frame, cookie, this,
|
||||
op_ret, op_errno,
|
||||
path, buf, xdata)
|
||||
self.stub_refs["readlink_cbk"] = stub
|
||||
dl.set_readlink_cbk(c_this,stub)
|
||||
if "mkdir_fop" in funcs:
|
||||
@OpMkdir.fop_type
|
||||
def stub (frame, this, loc, mode, umask, xdata,
|
||||
s=self):
|
||||
return s.mkdir_fop (frame, this, loc, mode,
|
||||
umask, xdata)
|
||||
self.stub_refs["mkdir_fop"] = stub
|
||||
dl.set_mkdir_fop(c_this,stub)
|
||||
if "mkdir_cbk" in funcs:
|
||||
@OpMkdir.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno, inode,
|
||||
buf, preparent, postparent, xdata, s=self):
|
||||
return s.mkdir_cbk (frame, cookie, this,
|
||||
op_ret, op_errno, inode,
|
||||
buf, preparent,
|
||||
postparent, xdata)
|
||||
self.stub_refs["mkdir_cbk"] = stub
|
||||
dl.set_mkdir_cbk(c_this,stub)
|
||||
if "rmdir_fop" in funcs:
|
||||
@OpRmdir.fop_type
|
||||
def stub (frame, this, loc, xflags,
|
||||
xdata, s=self):
|
||||
return s.rmdir_fop (frame, this, loc,
|
||||
xflags, xdata)
|
||||
self.stub_refs["rmdir_fop"] = stub
|
||||
dl.set_rmdir_fop(c_this,stub)
|
||||
if "rmdir_cbk" in funcs:
|
||||
@OpRmdir.cbk_type
|
||||
def stub (frame, cookie, this, op_ret, op_errno,
|
||||
preparent, postparent, xdata, s=self):
|
||||
return s.rmdir_cbk (frame, cookie, this,
|
||||
op_ret, op_errno,
|
||||
preparent, postparent,
|
||||
xdata)
|
||||
self.stub_refs["rmdir_cbk"] = stub
|
||||
dl.set_rmdir_cbk(c_this,stub)
|
||||
|
@ -1,4 +1,5 @@
|
||||
import sys
|
||||
from uuid import UUID
|
||||
from gluster import *
|
||||
|
||||
# Negative-lookup-caching example. If a file wasn't there the last time we
|
||||
@ -19,75 +20,73 @@ cache = {}
|
||||
dl.get_id.restype = c_long
|
||||
dl.get_id.argtypes = [ POINTER(call_frame_t) ]
|
||||
|
||||
def uuid2str (orig):
|
||||
return "%08x%08x%08x%08x" % (orig[0], orig[1], orig[2], orig[3])
|
||||
def uuid2str (gfid):
|
||||
return str(UUID(''.join(map("{0:02x}".format, gfid))))
|
||||
|
||||
class xlator (Translator):
|
||||
|
||||
def __init__ (self, c_this):
|
||||
self.requests = {}
|
||||
Translator.__init__(self,c_this)
|
||||
def __init__ (self, c_this):
|
||||
self.requests = {}
|
||||
Translator.__init__(self,c_this)
|
||||
|
||||
def lookup_fop (self, frame, this, loc, xdata):
|
||||
pargfid = uuid2str(loc.contents.pargfid)
|
||||
print "lookup FOP: %s:%s" % (pargfid, loc.contents.name)
|
||||
# Check the cache.
|
||||
if cache.has_key(pargfid):
|
||||
if loc.contents.name in cache[pargfid]:
|
||||
print "short-circuiting for %s:%s" % (
|
||||
pargfid, loc.contents.name)
|
||||
dl.unwind_lookup(frame,0,this,-1,2,None,None,
|
||||
None,None)
|
||||
return 0
|
||||
key = dl.get_id(frame)
|
||||
self.requests[key] = (pargfid, loc.contents.name[:])
|
||||
# TBD: get real child xl from init, pass it here
|
||||
dl.wind_lookup(frame,POINTER(xlator_t)(),loc,xdata)
|
||||
return 0
|
||||
def lookup_fop (self, frame, this, loc, xdata):
|
||||
pargfid = uuid2str(loc.contents.pargfid)
|
||||
print "lookup FOP: %s:%s" % (pargfid, loc.contents.name)
|
||||
# Check the cache.
|
||||
if cache.has_key(pargfid):
|
||||
if loc.contents.name in cache[pargfid]:
|
||||
print "short-circuiting for %s:%s" % (pargfid,
|
||||
loc.contents.name)
|
||||
dl.unwind_lookup(frame,0,this,-1,2,None,None,None,None)
|
||||
return 0
|
||||
key = dl.get_id(frame)
|
||||
self.requests[key] = (pargfid, loc.contents.name[:])
|
||||
# TBD: get real child xl from init, pass it here
|
||||
dl.wind_lookup(frame,POINTER(xlator_t)(),loc,xdata)
|
||||
return 0
|
||||
|
||||
def lookup_cbk (self, frame, cookie, this, op_ret, op_errno, inode, buf,
|
||||
xdata, postparent):
|
||||
print "lookup CBK: %d (%d)" % (op_ret, op_errno)
|
||||
key = dl.get_id(frame)
|
||||
pargfid, name = self.requests[key]
|
||||
# Update the cache.
|
||||
if op_ret == 0:
|
||||
print "found %s, removing from cache" % name
|
||||
if cache.has_key(pargfid):
|
||||
cache[pargfid].discard(name)
|
||||
elif op_errno == 2: # ENOENT
|
||||
print "failed to find %s, adding to cache" % name
|
||||
if cache.has_key(pargfid):
|
||||
cache[pargfid].add(name)
|
||||
else:
|
||||
cache[pargfid] = set([name])
|
||||
del self.requests[key]
|
||||
dl.unwind_lookup(frame,cookie,this,op_ret,op_errno,
|
||||
inode,buf,xdata,postparent)
|
||||
return 0
|
||||
def lookup_cbk (self, frame, cookie, this, op_ret, op_errno, inode, buf,
|
||||
xdata, postparent):
|
||||
print "lookup CBK: %d (%d)" % (op_ret, op_errno)
|
||||
key = dl.get_id(frame)
|
||||
pargfid, name = self.requests[key]
|
||||
# Update the cache.
|
||||
if op_ret == 0:
|
||||
print "found %s, removing from cache" % name
|
||||
if cache.has_key(pargfid):
|
||||
cache[pargfid].discard(name)
|
||||
elif op_errno == 2: # ENOENT
|
||||
print "failed to find %s, adding to cache" % name
|
||||
if cache.has_key(pargfid):
|
||||
cache[pargfid].add(name)
|
||||
else:
|
||||
cache[pargfid] = set([name])
|
||||
del self.requests[key]
|
||||
dl.unwind_lookup(frame,cookie,this,op_ret,op_errno,
|
||||
inode,buf,xdata,postparent)
|
||||
return 0
|
||||
|
||||
def create_fop (self, frame, this, loc, flags, mode, umask, fd, xdata):
|
||||
pargfid = uuid2str(loc.contents.pargfid)
|
||||
print "create FOP: %s:%s" % (pargfid, loc.contents.name)
|
||||
key = dl.get_id(frame)
|
||||
self.requests[key] = (pargfid, loc.contents.name[:])
|
||||
# TBD: get real child xl from init, pass it here
|
||||
dl.wind_create(frame,POINTER(xlator_t)(),loc,flags,mode,umask,
|
||||
fd,xdata)
|
||||
return 0
|
||||
def create_fop (self, frame, this, loc, flags, mode, umask, fd, xdata):
|
||||
pargfid = uuid2str(loc.contents.pargfid)
|
||||
print "create FOP: %s:%s" % (pargfid, loc.contents.name)
|
||||
key = dl.get_id(frame)
|
||||
self.requests[key] = (pargfid, loc.contents.name[:])
|
||||
# TBD: get real child xl from init, pass it here
|
||||
dl.wind_create(frame,POINTER(xlator_t)(),loc,flags,mode,umask,fd,xdata)
|
||||
return 0
|
||||
|
||||
def create_cbk (self, frame, cookie, this, op_ret, op_errno, fd, inode,
|
||||
buf, preparent, postparent, xdata):
|
||||
print "create CBK: %d (%d)" % (op_ret, op_errno)
|
||||
key = dl.get_id(frame)
|
||||
pargfid, name = self.requests[key]
|
||||
# Update the cache.
|
||||
if op_ret == 0:
|
||||
print "created %s, removing from cache" % name
|
||||
if cache.has_key(pargfid):
|
||||
cache[pargfid].discard(name)
|
||||
del self.requests[key]
|
||||
dl.unwind_create(frame,cookie,this,op_ret,op_errno,fd,inode,buf,
|
||||
preparent,postparent,xdata)
|
||||
return 0
|
||||
def create_cbk (self, frame, cookie, this, op_ret, op_errno, fd, inode,
|
||||
buf, preparent, postparent, xdata):
|
||||
print "create CBK: %d (%d)" % (op_ret, op_errno)
|
||||
key = dl.get_id(frame)
|
||||
pargfid, name = self.requests[key]
|
||||
# Update the cache.
|
||||
if op_ret == 0:
|
||||
print "created %s, removing from cache" % name
|
||||
if cache.has_key(pargfid):
|
||||
cache[pargfid].discard(name)
|
||||
del self.requests[key]
|
||||
dl.unwind_create(frame,cookie,this,op_ret,op_errno,fd,inode,buf,
|
||||
preparent,postparent,xdata)
|
||||
return 0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user