Skip to content

Commit

Permalink
Improving readcache check for file based SRs
Browse files Browse the repository at this point in the history
The check introduced with commit 4be47e0 happens in the
load function.
This means that it has to be done for the load function
of every file based SR.

Putting the check in the FileSR constructor will make
it available for every derived class, without the need
to add the check for every new SR (as it happened to
me while playing with OCFSSR)

The initial version was using "super" instead of an explicit
call to SR.SR.__init__ but the former proved to be unreliable
where there are many circular imports, failing to identify
objects of the same type just because there id was changed
in subsequent import calls.

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
[initial review]
Reviewed-by: Thanos Makatos <thanos.makatos@citrix.com>
  • Loading branch information
germanop committed Aug 5, 2015
1 parent a04cbb3 commit fc2cdfd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions drivers/EXTSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ def load(self, sr_uuid):
self.attached = self._checkmount()
self.driver_config = DRIVER_CONFIG

self._check_o_direct()

def delete(self, sr_uuid):
super(EXTSR, self).delete(sr_uuid)

Expand Down
10 changes: 8 additions & 2 deletions drivers/FileSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def _check_o_direct(self):
else:
self.o_direct = True


def __init__(self, srcmd, sr_uuid):
# We call SR.SR.__init__ explicitly because
# "super" sometimes failed due to circular imports
SR.SR.__init__(self, srcmd, sr_uuid)
self._check_o_direct()


def load(self, sr_uuid):
self.ops_exclusive = OPS_EXCLUSIVE
self.lock = Lock(vhdutil.LOCK_TYPE_SR, self.uuid)
Expand All @@ -99,8 +107,6 @@ def load(self, sr_uuid):
self.attached = False
self.driver_config = DRIVER_CONFIG

self._check_o_direct()

def create(self, sr_uuid, size):
""" Create the SR. The path must not already exist, or if it does,
it must be empty. (This accounts for the case where the user has
Expand Down
2 changes: 0 additions & 2 deletions drivers/NFSSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ def load(self, sr_uuid):
self.transport = "udp"
self.nfsversion = nfs.validate_nfsversion(self.dconf.get('nfsversion'))

self._check_o_direct()


def validate_remotepath(self, scan):
if not self.dconf.has_key('serverpath'):
Expand Down

0 comments on commit fc2cdfd

Please sign in to comment.