fileobj/devobj: record path name (originally by Takagi-san)
This commit is contained in:
@ -1182,6 +1182,7 @@ struct pager_create_result {
|
|||||||
int maxprot;
|
int maxprot;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
char path[PATH_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -1200,6 +1201,33 @@ enum {
|
|||||||
MF_END
|
MF_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int pager_get_path(struct file *file, char *path) {
|
||||||
|
int error = 0;
|
||||||
|
char *pathbuf, *fullpath;
|
||||||
|
|
||||||
|
pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY);
|
||||||
|
if (!pathbuf) {
|
||||||
|
printk("%s: ERROR: allocating path\n", __FUNCTION__);
|
||||||
|
error = -ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
fullpath = d_path(&file->f_path, pathbuf, PATH_MAX);
|
||||||
|
if (!IS_ERR(fullpath)) {
|
||||||
|
memcpy(path, fullpath, strlen(fullpath));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
path[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (pathbuf) {
|
||||||
|
kfree(pathbuf);
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int pager_req_create(ihk_os_t os, int fd, uintptr_t result_pa)
|
static int pager_req_create(ihk_os_t os, int fd, uintptr_t result_pa)
|
||||||
{
|
{
|
||||||
ihk_device_t dev = ihk_os_to_dev(os);
|
ihk_device_t dev = ihk_os_to_dev(os);
|
||||||
@ -1333,6 +1361,7 @@ found:
|
|||||||
phys = ihk_device_map_memory(dev, result_pa, sizeof(*resp));
|
phys = ihk_device_map_memory(dev, result_pa, sizeof(*resp));
|
||||||
resp = ihk_device_map_virtual(dev, phys, sizeof(*resp), NULL, 0);
|
resp = ihk_device_map_virtual(dev, phys, sizeof(*resp), NULL, 0);
|
||||||
if (!resp) {
|
if (!resp) {
|
||||||
|
ihk_device_unmap_memory(dev, phys, sizeof(*resp));
|
||||||
printk("%s: ERROR: invalid response structure address\n",
|
printk("%s: ERROR: invalid response structure address\n",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
error = -EINVAL;
|
error = -EINVAL;
|
||||||
@ -1343,10 +1372,18 @@ found:
|
|||||||
resp->maxprot = maxprot;
|
resp->maxprot = maxprot;
|
||||||
resp->flags = mf_flags;
|
resp->flags = mf_flags;
|
||||||
resp->size = st.size;
|
resp->size = st.size;
|
||||||
|
|
||||||
|
error = pager_get_path(file, resp->path);
|
||||||
|
if (error) {
|
||||||
|
goto out_unmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = 0;
|
||||||
|
|
||||||
|
out_unmap:
|
||||||
ihk_device_unmap_virtual(dev, resp, sizeof(*resp));
|
ihk_device_unmap_virtual(dev, resp, sizeof(*resp));
|
||||||
ihk_device_unmap_memory(dev, phys, sizeof(*resp));
|
ihk_device_unmap_memory(dev, phys, sizeof(*resp));
|
||||||
|
|
||||||
error = 0;
|
|
||||||
out:
|
out:
|
||||||
if (newpager) {
|
if (newpager) {
|
||||||
kfree(newpager);
|
kfree(newpager);
|
||||||
@ -1578,6 +1615,7 @@ struct pager_map_result {
|
|||||||
uintptr_t handle;
|
uintptr_t handle;
|
||||||
int maxprot;
|
int maxprot;
|
||||||
int8_t padding[4];
|
int8_t padding[4];
|
||||||
|
char path[PATH_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off,
|
static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off,
|
||||||
@ -1665,6 +1703,7 @@ static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off,
|
|||||||
phys = ihk_device_map_memory(dev, result_rpa, sizeof(*resp));
|
phys = ihk_device_map_memory(dev, result_rpa, sizeof(*resp));
|
||||||
resp = ihk_device_map_virtual(dev, phys, sizeof(*resp), NULL, 0);
|
resp = ihk_device_map_virtual(dev, phys, sizeof(*resp), NULL, 0);
|
||||||
if (!resp) {
|
if (!resp) {
|
||||||
|
ihk_device_unmap_memory(dev, phys, sizeof(*resp));
|
||||||
printk("%s: ERROR: invalid response structure address\n",
|
printk("%s: ERROR: invalid response structure address\n",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
error = -EINVAL;
|
error = -EINVAL;
|
||||||
@ -1673,13 +1712,16 @@ static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off,
|
|||||||
|
|
||||||
resp->handle = (uintptr_t)pager;
|
resp->handle = (uintptr_t)pager;
|
||||||
resp->maxprot = maxprot;
|
resp->maxprot = maxprot;
|
||||||
ihk_device_unmap_virtual(dev, resp, sizeof(*resp));
|
|
||||||
ihk_device_unmap_memory(dev, phys, sizeof(*resp));
|
error = pager_get_path(file, resp->path);
|
||||||
|
if (error) {
|
||||||
|
goto out_unmap;
|
||||||
|
}
|
||||||
|
|
||||||
error = down_interruptible(&ppd->devobj_pager_lock);
|
error = down_interruptible(&ppd->devobj_pager_lock);
|
||||||
if (error) {
|
if (error) {
|
||||||
error = -EINTR;
|
error = -EINTR;
|
||||||
goto out;
|
goto out_unmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_add_tail(&pager->list, &ppd->devobj_pager_list);
|
list_add_tail(&pager->list, &ppd->devobj_pager_list);
|
||||||
@ -1688,6 +1730,10 @@ static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off,
|
|||||||
pager = 0;
|
pager = 0;
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
|
out_unmap:
|
||||||
|
ihk_device_unmap_virtual(dev, resp, sizeof(*resp));
|
||||||
|
ihk_device_unmap_memory(dev, phys, sizeof(*resp));
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (file) {
|
if (file) {
|
||||||
fput(file);
|
fput(file);
|
||||||
|
|||||||
@ -136,6 +136,18 @@ int devobj_create(int fd, size_t len, off_t off, struct memobj **objp, int *maxp
|
|||||||
obj->memobj.flags = MF_HAS_PAGER | MF_DEV_FILE;
|
obj->memobj.flags = MF_HAS_PAGER | MF_DEV_FILE;
|
||||||
obj->memobj.size = len;
|
obj->memobj.size = len;
|
||||||
obj->handle = result.handle;
|
obj->handle = result.handle;
|
||||||
|
|
||||||
|
dkprintf("%s: path=%s\n", __FUNCTION__, result.path);
|
||||||
|
if (result.path[0]) {
|
||||||
|
obj->memobj.path = kmalloc(PATH_MAX, IHK_MC_AP_NOWAIT);
|
||||||
|
if (!obj->memobj.path) {
|
||||||
|
error = -ENOMEM;
|
||||||
|
kprintf("%s: ERROR: Out of memory\n", __FUNCTION__);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
strncpy(obj->memobj.path, result.path, PATH_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
obj->ref = 1;
|
obj->ref = 1;
|
||||||
obj->pfn_pgoff = off / PAGE_SIZE;
|
obj->pfn_pgoff = off / PAGE_SIZE;
|
||||||
obj->npages = npages;
|
obj->npages = npages;
|
||||||
@ -217,6 +229,11 @@ static void devobj_release(struct memobj *memobj)
|
|||||||
ihk_mc_free_pages(obj->pfn_table, pfn_npages);
|
ihk_mc_free_pages(obj->pfn_table, pfn_npages);
|
||||||
#endif /*POSTK_DEBUG_TEMP_FIX_36*/
|
#endif /*POSTK_DEBUG_TEMP_FIX_36*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (to_memobj(free_obj)->path) {
|
||||||
|
kfree(to_memobj(free_obj)->path);
|
||||||
|
}
|
||||||
|
|
||||||
kfree(free_obj);
|
kfree(free_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -223,6 +223,18 @@ int fileobj_create(int fd, struct memobj **objp, int *maxprotp, uintptr_t virt_a
|
|||||||
newobj->memobj.ops = &fileobj_ops;
|
newobj->memobj.ops = &fileobj_ops;
|
||||||
newobj->memobj.flags = MF_HAS_PAGER | MF_REG_FILE;
|
newobj->memobj.flags = MF_HAS_PAGER | MF_REG_FILE;
|
||||||
newobj->handle = result.handle;
|
newobj->handle = result.handle;
|
||||||
|
dkprintf("%s: path=%s\n", __FUNCTION__, result.path);
|
||||||
|
|
||||||
|
if (result.path[0]) {
|
||||||
|
newobj->memobj.path = kmalloc(PATH_MAX, IHK_MC_AP_NOWAIT);
|
||||||
|
if (!newobj->memobj.path) {
|
||||||
|
error = -ENOMEM;
|
||||||
|
kprintf("%s: error: allocating path\n", __FUNCTION__);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
strncpy(newobj->memobj.path, result.path, PATH_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
newobj->sref = 1;
|
newobj->sref = 1;
|
||||||
newobj->cref = 1;
|
newobj->cref = 1;
|
||||||
fileobj_page_hash_init(newobj);
|
fileobj_page_hash_init(newobj);
|
||||||
@ -434,6 +446,10 @@ static void fileobj_release(struct memobj *memobj)
|
|||||||
kfree(to_memobj(free_obj)->pages);
|
kfree(to_memobj(free_obj)->pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (to_memobj(free_obj)->path) {
|
||||||
|
kfree(to_memobj(free_obj)->path);
|
||||||
|
}
|
||||||
|
|
||||||
obj_list_remove(free_obj);
|
obj_list_remove(free_obj);
|
||||||
mcs_lock_unlock_noirq(&fileobj_list_lock, &node);
|
mcs_lock_unlock_noirq(&fileobj_list_lock, &node);
|
||||||
kfree(free_obj);
|
kfree(free_obj);
|
||||||
|
|||||||
@ -61,6 +61,7 @@ struct memobj {
|
|||||||
/* For pre-mapped memobjects */
|
/* For pre-mapped memobjects */
|
||||||
void **pages;
|
void **pages;
|
||||||
int nr_pages;
|
int nr_pages;
|
||||||
|
char *path;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void memobj_release_func_t(struct memobj *obj);
|
typedef void memobj_release_func_t(struct memobj *obj);
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#define HEADER_PAGER_H
|
#define HEADER_PAGER_H
|
||||||
|
|
||||||
#include <ihk/types.h>
|
#include <ihk/types.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
enum pager_op {
|
enum pager_op {
|
||||||
PAGER_REQ_CREATE = 0x0001,
|
PAGER_REQ_CREATE = 0x0001,
|
||||||
@ -32,6 +33,7 @@ struct pager_create_result {
|
|||||||
int maxprot;
|
int maxprot;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
char path[PATH_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -46,6 +48,7 @@ struct pager_map_result {
|
|||||||
uintptr_t handle;
|
uintptr_t handle;
|
||||||
int maxprot;
|
int maxprot;
|
||||||
int8_t padding[4];
|
int8_t padding[4];
|
||||||
|
char path[PATH_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* for pager_req_pfn() */
|
/* for pager_req_pfn() */
|
||||||
|
|||||||
Reference in New Issue
Block a user