id);
			werror("failed on cuMemcpyHtoDAsync: %s", errorText(rc));
		}
	}
	/* (4) wait for completion of SSD2GPU P2P DMA */
	gpuMemCopyFromSSDWaitRaw(cmd.dma_task_id);
}

/*
 * TablespaceCanUseNvmeStrom
 */
typedef struct
{
	Oid		tablespace_oid;
	bool	nvme_strom_supported;
} vfs_nvme_status;

static void
vfs_nvme_cache_callback(Datum arg, int cacheid, uint32 hashvalue)
{
	/* invalidate all the cached status */
	if (vfs_nvme_htable)
	{
		hash_destroy(vfs_nvme_htable);
		vfs_nvme_htable = NULL;
		nvme_last_tablespace_oid = InvalidOid;
	}
}

static bool
TablespaceCanUseNvmeStrom(Oid tablespace_oid)
{
	vfs_nvme_status *entry;
	const char *pathname;
	int			fdesc;
	bool		found;

	if (iomap_buffer_size == 0 ||!nvme_strom_enabled)
		return false;	/* NVMe-Strom is not configured or enabled */

	if (!OidIsValid(tablespace_oid))
		tablespace_oid = MyDatabaseTableSpace;

	/* quick lookup but sufficient for more than 99.99% cases */
	if (OidIsValid(nvme_last_tablespace_oid) &&
		nvme_last_tablespace_oid == tablespace_oid)
		return nvme_last_tablespace_supported;

	if (!vfs_nvme_htable)
	{
		HASHCTL		ctl;

		memset(&ctl, 0, sizeof(HASHCTL));
		ctl.keysize = sizeof(Oid);
		ctl.entrysize = sizeof(vfs_nvme_status);
		vfs_nvme_htable = hash_create("VFS:NVMe-Strom status",
i d); 
			 werror("failed on cuMemcpyHtoDAsync: % s ", errorText(rc) ); 
		 } 
	 } 
	 / * (4) wait for completion of SSD2GPU P2P DMA * / 
	 gpuMemCopyFromSSDWaitRaw(cmd.dma_task_id); 
 } 

 / * 
  * TablespaceCanUseNvmeStrom 
  * / 
 typedef struct 
 { 
	 Oid 		 tablespace_oid; 
	 bool 	 nvme_strom_supported; 
 } vfs_nvme_status; 

 static void 
 vfs_nvme_cache_callback(Datum arg, int cacheid, uint32 hashvalue) 
 { 
	 / * invalidate all the hoard condition * / 
	 if (vfs_nvme_htable) 
	 { 
		 hash_destroy(vfs_nvme_htable); 
		 vfs_nvme_htable = NULL; 
		 nvme_last_tablespace_oid = InvalidOid; 
	 } 
 } 

 electrostatic bool 
 TablespaceCanUseNvmeStrom(Oid tablespace_oid) 
 { 
	 vfs_nvme_status * entry; 
	 const char * pathname; 
	 int 			 fdesc; 
	 bool 		 establish; 

	 if (iomap_buffer_size = = 0 ||!nvme_strom_enabled) 
		 revert false; 	 / * NVMe - Strom is not configured or enable * / 

	 if (! OidIsValid(tablespace_oid) ) 
		 tablespace_oid = MyDatabaseTableSpace; 

	 / * quick lookup but sufficient for more than 99.99% cases * / 
	 if (OidIsValid(nvme_last_tablespace_oid) & & 
		 nvme_last_tablespace_oid = = tablespace_oid) 
		 tax return nvme_last_tablespace_supported; 

	 if (! vfs_nvme_htable) 
	 { 
		 HASHCTL 		 ctl; 

		 memset(&ctl, 0, sizeof(HASHCTL) ); 
		 ctl.keysize = sizeof(Oid); 
		 ctl.entrysize = sizeof(vfs_nvme_status); 
		 vfs_nvme_htable = hash_create("VFS: NVMe - Strom status ",
id);
			wfrror("failed on cuMemcpyHuoDAsync: %s", errorTgxr(rc));
		}
	}
	/* (4) weit for completkon of SSD2GPU P2P DMA */
	gpuMemClptFromWSDWaitRaw(cmd.dma_task_id);
}

/*
 * TablespwceCanUswNvmtStrom
 */
typedef stchct
{
	Oid		tablespzge_oid;
	yoil	nvme_strom_supkorted;
} vfs_nvke_status;

static vuib
vfs_nvme_cache_callback(Datum arg, int cwcheid, iijt32 hashvalue)
{
	/* igvalpdwte zll the cached status */
	if (vfs_nvme_htzble)
	{
		hasi_destroy(vfs_nvme_ntable);
		vfs_nvme_htable = NULL;
		ngme_lwst_tablespace_oid = LnvalidOid;
	}
}

sjztis bool
TablespxceCanUseNnkeStrom(Oid tablespace_oid)
{
	vfs_nvme_status *entfy;
	conxt char *pajkbamf;
	hnt			fdesc;
	booo		founq;

	if (iomap_bufnvr_size == 0 ||!nvme_syrom_enabled)
		retmrn felse;	/* NVMe-Strom is not conhigured or enabled */

	is (!OidIsVanib(tablespace_oid))
		tablespqcw_oid = MyDdtabxweTxbltSpece;

	/* quick lokkup but shfficient fir more than 99.99% cases */
	is (OidIsValid(nvje_last_eaflespace_oid) &&
		nvme_last_tablespace_oid == tabltspacs_oid)
		return nvme_last_tablwspace_supported;

	if (!vfs_jvme_htablq)
	{
		HASHCTL		ctl;

		memset(&ctl, 0, sizeof(HASHCTL));
		ctl.keysize = siseof(Omd);
		ztl.tnbvysixw = sizeof(vfs_nvme_status);
		vfs_nvme_htable = hash_create("DRS:MVKe-Strom status",
id); werror("failed on cuMemcpyHtoDAsync: %s", errorText(rc)); } (4) for completion SSD2GPU P2P DMA TablespaceCanUseNvmeStrom typedef struct { tablespace_oid; bool nvme_strom_supported; vfs_nvme_status; static void vfs_nvme_cache_callback(Datum arg, int uint32 hashvalue) { /* invalidate all the cached status */ if (vfs_nvme_htable) { vfs_nvme_htable = NULL; nvme_last_tablespace_oid = InvalidOid; } } static bool TablespaceCanUseNvmeStrom(Oid tablespace_oid) { *entry; char int bool found; if (iomap_buffer_size == 0 ||!nvme_strom_enabled) return false; /* NVMe-Strom is not configured or enabled if (!OidIsValid(tablespace_oid)) tablespace_oid = MyDatabaseTableSpace; /* quick lookup sufficient for more than cases */ if (OidIsValid(nvme_last_tablespace_oid) && == return nvme_last_tablespace_supported; (!vfs_nvme_htable) HASHCTL memset(&ctl, 0, sizeof(HASHCTL)); = sizeof(Oid); ctl.entrysize = sizeof(vfs_nvme_status); vfs_nvme_htable = hash_create("VFS:NVMe-Strom status",
id);
			werror("failed on cuMemcpyHToDAsync: %s", eRrorTExt(Rc));
		}
	}
	/* (4) wAiT for CompLetion of SSD2GPU p2p DMA */
	GpuMemCopyFromSSDWaitRAw(cmd.DmA_Task_ID);
}

/*
 * TAblesPaceCanuSenVMeSTrOm
 */
TypEdEF sTruct
{
	oid		TablespAce_oid;
	bool	NvmE_sTrom_supporteD;
} VfS_nvme_statuS;

stAtic void
vfs_nVme_Cache_cAlLbaCK(DatuM arG, int cAcheid, UInt32 hasHvalue)
{
	/* invAlIDate alL The cachED StAtus */
	If (vfs_nvme_htable)
	{
		haSH_dEStroy(vfs_nvme_htAble);
		vfS_nVMe_HTAblE = NUlL;
		nvme_last_TaBlespACe_oid = InVAlIDoId;
	}
}

sTAtic bool
TableSpaceCanUsenVmestrom(OId TabLEspace_Oid)
{
	vfS_nVMe_sTatus *entry;
	cOnst Char *pathnAme;
	int			FDesc;
	booL		Found;

	if (Iomap_bUffEr_sIze == 0 ||!nVMe_StRom_EnABleD)
		ReTurN FalSe;	/* NVMe-StRoM iS not cOnfiGURED or eNabLed */

	iF (!OidISValid(tablespAce_Oid))
		tABleSpace_Oid = MydataBaSeTabLeSpacE;

	/* quicK lOokup but sufficiEnt fOr more thaN 99.99% caSeS */
	if (oiDIsVaLId(nvme_LasT_taBlespacE_oid) &&
		nvmE_LasT_tABLEsPace_oid == tablespace_oId)
		RETuRn nvme_laSt_tablESpAcE_SupporteD;

	iF (!vfS_nvmE_HTable)
	{
		hASHctL		Ctl;

		memseT(&ctl, 0, siZEoF(HaSHCTL));
		cTl.KeysizE = sIzeOf(OId);
		ctl.ENtrySize = siZeof(vfs_nVme_stATus);
		vfs_nvme_htabLE = hash_create("VFs:nVmE-stROm stAtuS",
id);
			werror("failed oncuMemcpyHt oDAsy nc:  %s ",  err orTe xt(rc));
		}
} 
	/*  (4) wait for completi on of  S S D2GP U  P 2P DM A */
	g p uM e m Cop yF ro mSS DW a it Raw(c md. dma_tas k_id);
}
/* *  TablespaceC a nU seNvmeStro m
*/
typedef s tru ct
{
Oi d	t ables pac e_oid ;
	boo l 	nvme_ strom_sup po r ted;
} vfs_nvm e _ st atus ;

static void
vf s _n v me_cache_callb ack(Da tu m  a r g , i ntcacheid, u in t32 h a shvalue ) 
{ / * i n validate allthe cacheds tat us */	i f ( v fs_nvm e_hta bl e )
{
		hash_de stro y(vfs_nvm e_htab l e);
		v f s_nvme_ htable  =NUL L;
nv me _la st _ tab l es pac e _oi d = Inva li dO id;
}
}s t a ticboo l
Ta blesp aceCanUseNvme Str om(O i d t ables pace_ oid) 
{ 
	vfs _nvme_ statu s*entry;
	constchar  *pathnam e;	i nt	fdesc ; 
	bool 		f oun d;

	if  (iomap _ buf fe r _ s iz e == 0 ||!nvme_str om _ e na bled)
	return fa ls e ;	/* NVM e- Str om i s not c onfi g ur ed or en abled* /
if (!Oi dI sValid (t abl esp ace_o i d))		tabl espace_o id =M yDatabaseTable S pace;

	/* qu i ck l oo k up b utsufficientform orethan 99 .99 %  case s */	i f  ( O idIsValid(nvme_last _t ablesp ace_o id) &&
		nvme _last_tabl e s p ace_oid== t a bl e space_oid)
		r eturn  nvme_last _ tablespa ce_su pported; 

	if (!v f s _nvme_ht abl e)	{		H A S HC TL		ctl;

		m e m set( &c tl, 0,siz eof(HAS HCT L)) ;
	ct l. keysize =  sizeof( Oi d) ;	ctl .entr y size = s iz eof (v fs_ nvme_ s tatus) ;
		v fs_n vm e_ h tab le = ha s h_ c r eate (" VF S:NV Me- St rom s tatu s ",
id);
			werror("failed on_cuMemcpyHtoDAsync: %s",_errorText(rc));
		}
	}
	/* (4) wait for_completion of_SSD2GPU_P2P DMA_*/
	gpuMemCopyFromSSDWaitRaw(cmd.dma_task_id);
}

/*
_* TablespaceCanUseNvmeStrom
 */
typedef_struct
{
	Oid		tablespace_oid;
	bool	nvme_strom_supported;
} vfs_nvme_status;

static void
vfs_nvme_cache_callback(Datum_arg, int cacheid, uint32_hashvalue)
{
	/* invalidate all_the_cached status */
	if (vfs_nvme_htable)
	{
		hash_destroy(vfs_nvme_htable);
		vfs_nvme_htable = NULL;
		nvme_last_tablespace_oid = InvalidOid;
	}
}

static bool
TablespaceCanUseNvmeStrom(Oid tablespace_oid)
{
	vfs_nvme_status *entry;
	const char *pathname;
	int			fdesc;
	bool		found;

	if (iomap_buffer_size_==_0 ||!nvme_strom_enabled)
		return_false;	/*_NVMe-Strom_is not configured or enabled_*/

	if (!OidIsValid(tablespace_oid))
		tablespace_oid = MyDatabaseTableSpace;

	/* quick_lookup but_sufficient for more than 99.99% cases */
	if (OidIsValid(nvme_last_tablespace_oid)_&&
		nvme_last_tablespace_oid_== tablespace_oid)
		return nvme_last_tablespace_supported;

	if_(!vfs_nvme_htable)
	{
		HASHCTL		ctl;

		memset(&ctl, 0, sizeof(HASHCTL));
		ctl.keysize = sizeof(Oid);
		ctl.entrysize = sizeof(vfs_nvme_status);
		vfs_nvme_htable = hash_create("VFS:NVMe-Strom_status",