mirror of
https://github.com/schoebel/mars
synced 2025-02-21 23:06:51 +00:00
infra: propagate any open error code
This commit is contained in:
parent
12d3b7ed61
commit
e58a5e4cee
@ -155,7 +155,7 @@ void mapfree_put(struct mapfree_info *mf)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mapfree_put);
|
||||
|
||||
struct mapfree_info *mapfree_get(const char *name, int flags)
|
||||
struct mapfree_info *mapfree_get(const char *name, int flags, int *error)
|
||||
{
|
||||
struct mapfree_info *mf = NULL;
|
||||
struct list_head *tmp;
|
||||
@ -241,6 +241,9 @@ struct mapfree_info *mapfree_get(const char *name, int flags)
|
||||
|
||||
if (unlikely(!mf->mf_filp || IS_ERR(mf->mf_filp))) {
|
||||
int err = PTR_ERR(mf->mf_filp);
|
||||
|
||||
if (error)
|
||||
*error = err;
|
||||
MARS_ERR("can't open file '%s' status=%d\n", name, err);
|
||||
mf->mf_filp = NULL;
|
||||
_mapfree_put(mf);
|
||||
|
@ -78,7 +78,7 @@ struct mapfree_info {
|
||||
struct dirty_length mf_length[DIRTY_MAX];
|
||||
};
|
||||
|
||||
struct mapfree_info *mapfree_get(const char *filename, int flags);
|
||||
struct mapfree_info *mapfree_get(const char *filename, int flags, int *error);
|
||||
|
||||
void mapfree_put(struct mapfree_info *mf);
|
||||
|
||||
|
@ -1243,10 +1243,14 @@ static int aio_switch(struct aio_brick *brick)
|
||||
MARS_DBG("using O_DIRECT on %s\n", path);
|
||||
}
|
||||
|
||||
output->mf = mapfree_get(path, flags);
|
||||
output->error = 0;
|
||||
output->mf = mapfree_get(path, flags, &output->error);
|
||||
if (unlikely(!output->mf)) {
|
||||
MARS_ERR("could not open file = '%s' flags = %d\n", path, flags);
|
||||
status = -ENOENT;
|
||||
MARS_ERR("could not open file = '%s' flags = %d error = %d\n",
|
||||
path, flags, output->error);
|
||||
status = output->error;
|
||||
if (!status)
|
||||
status = -ENOENT;
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,7 @@ struct aio_output {
|
||||
bool fdsync_active;
|
||||
// statistics
|
||||
int index;
|
||||
int error;
|
||||
atomic_t work_count;
|
||||
atomic_t read_count;
|
||||
atomic_t write_count;
|
||||
|
@ -831,10 +831,14 @@ static int bio_switch(struct bio_brick *brick)
|
||||
struct backing_dev_info *bdi;
|
||||
#endif
|
||||
|
||||
brick->mf = mapfree_get(path, flags);
|
||||
brick->error = 0;
|
||||
brick->mf = mapfree_get(path, flags, &brick->error);
|
||||
if (unlikely(!brick->mf)) {
|
||||
status = -ENOENT;
|
||||
MARS_ERR("cannot open file '%s'\n", path);
|
||||
status = brick->error;
|
||||
if (!status)
|
||||
status = -ENOENT;
|
||||
MARS_ERR("cannot open file '%s', error=%d\n",
|
||||
path, brick->error);
|
||||
goto done;
|
||||
}
|
||||
mapfree_pages(brick->mf, -1);
|
||||
|
@ -72,6 +72,7 @@ struct bio_brick {
|
||||
atomic_t fly_count[MARS_PRIO_NR];
|
||||
atomic_t queue_count[MARS_PRIO_NR];
|
||||
atomic_t completed_count;
|
||||
int error;
|
||||
#ifdef MARS_BIO_DEBUG
|
||||
atomic_t total_completed_count[MARS_PRIO_NR];
|
||||
#endif
|
||||
|
@ -638,9 +638,12 @@ static int sio_switch(struct sio_brick *brick)
|
||||
|
||||
mars_power_led_off((void*)brick, false);
|
||||
|
||||
output->mf = mapfree_get(path, flags);
|
||||
if (unlikely(IS_ERR(output->mf))) {
|
||||
status = PTR_ERR(output->mf);
|
||||
output->error = 0;
|
||||
output->mf = mapfree_get(path, flags, &output->error);
|
||||
if (unlikely(!output->mf || IS_ERR(output->mf))) {
|
||||
status = output->error;
|
||||
if (!status)
|
||||
status = -ENOENT;
|
||||
output->mf = NULL;
|
||||
MARS_ERR("open '%s' flags=%d status=%d\n",
|
||||
path,
|
||||
|
@ -66,6 +66,7 @@ struct sio_output {
|
||||
spinlock_t g_lock;
|
||||
atomic_t work_count;
|
||||
int index;
|
||||
int error;
|
||||
};
|
||||
|
||||
MARS_TYPES(sio);
|
||||
|
Loading…
Reference in New Issue
Block a user