diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-06-26 01:03:52 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-07-10 00:55:50 +0000 |
commit | ad961733c0afb96a7ab44dc9837a0f8c8fa239a4 (patch) | |
tree | 69bdbbec807c9bd3191dc59bdc1ab6ac37822956 /dev.c | |
parent | 70efa665edeef05f53978f9d541f411b0e1a2b2a (diff) | |
download | cmogstored-ad961733c0afb96a7ab44dc9837a0f8c8fa239a4.tar.gz |
This replaces the fsck_queue internals with a generic ioq implementation which is based on the MogileFS devid, and not the operating system devid.
Diffstat (limited to 'dev.c')
-rw-r--r-- | dev.c | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -31,14 +31,17 @@ static struct mog_dev *mog_dev_new(struct mog_svc *svc, uint32_t mog_devid) dev = mog_cachealign(sizeof(struct mog_dev)); dev->devid = mog_devid; dev->st_dev = sb.st_dev; + mog_ioq_init(&dev->fsckq, svc, 1); return dev; } -struct mog_dev *mog_dev_for(struct mog_svc *svc, uint32_t mog_devid) +struct mog_dev * +mog_dev_for(struct mog_svc *svc, uint32_t mog_devid, bool update) { struct mog_dev finder; struct mog_dev *ret; + bool need_refresh = false; finder.devid = mog_devid; @@ -47,6 +50,9 @@ struct mog_dev *mog_dev_for(struct mog_svc *svc, uint32_t mog_devid) if (ret) { struct stat sb; + if (!update) + goto out; + /* * devXXX dir existed before, but is no longer readable * Possible FS/device error, it could come back, so do @@ -67,13 +73,20 @@ struct mog_dev *mog_dev_for(struct mog_svc *svc, uint32_t mog_devid) case 0: assert(0 && "mog_dev existed while adding"); abort(); - case 1: break; /* OK, inserted */ + case 1: + if (!update) + need_refresh = true; + break; /* OK, inserted */ default: mog_oom(); } } out: CHECK(int, 0, pthread_mutex_unlock(&svc->by_mog_devid_lock)); + /* we need to get the notify thread to create new worker threads */ + if (need_refresh) + mog_notify(MOG_NOTIFY_DEVICE_REFRESH); + return ret; } @@ -222,3 +235,11 @@ out: } while (0)); return errno ? -1 : 0; } + +void mog_dev_free(void *ptr) +{ + struct mog_dev *dev = ptr; + + mog_ioq_destroy(&dev->fsckq); + free(dev); +} |