Skip to content

Commit

Permalink
Merge b8fdbf8 into c1de61a
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthv committed Mar 2, 2015
2 parents c1de61a + b8fdbf8 commit 639dc0f
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions drivers/blktap2.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,29 @@ def __init__(self, uuid, target, driver_info):
self._vdi_uuid = uuid
self._session = target.session
self.xenstore_data = scsiutil.update_XS_SCSIdata(uuid,scsiutil.gen_synthetic_page_data(uuid))
self.__o_direct = None
self.lock = Lock("vdi", uuid)

def get_o_direct_capability(self, options = {}):
"""Returns True/False based on licensing and caching_params"""
if self.__o_direct is not None:
return self.__o_direct

if not util.read_caching_is_restricted(self._session):
self.__o_direct = options.get(self.CONF_KEY_O_DIRECT)
if self.__o_direct is not None:
return self.__o_direct
if (self.target.vdi.sr.handles("nfs") or
self.target.vdi.sr.handles("ext")):
from FileSR import FileVDI
if vhdutil.getParent(self.target.vdi.path, FileVDI.extractUuid):
self.__o_direct = False

if self.__o_direct is None:
self.__o_direct = True

return self.__o_direct

@classmethod
def from_cli(cls, uuid):
import VDI as sm
Expand Down Expand Up @@ -1469,6 +1490,7 @@ def attach(self, sr_uuid, vdi_uuid, writable, activate = False):
# Return backend/ link
back_path = self.BackendLink.from_uuid(sr_uuid, vdi_uuid).path()
struct = { 'params': back_path,
'o_direct': self.get_o_direct_capability(),
'xenstore_data': self.xenstore_data}
util.SMlog('result: %s' % struct)

Expand Down Expand Up @@ -1562,12 +1584,7 @@ def _activate(self, sr_uuid, vdi_uuid, options):
# Maybe launch a tapdisk on the physical link
if self.tap_wanted():
vdi_type = self.target.get_vdi_type()
if util.read_caching_is_restricted(self._session):
options["o_direct"] = True
else:
options["o_direct"] = options.get(self.CONF_KEY_O_DIRECT)
if options["o_direct"] is None:
options["o_direct"] = True
options["o_direct"] = self.get_o_direct_capability(options)
dev_path = self._tap_activate(phy_path, vdi_type, sr_uuid,
options,
self._get_pool_config(sr_uuid).get("mem-pool-size"))
Expand Down

0 comments on commit 639dc0f

Please sign in to comment.