diff options
| author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-05-19 20:59:55 +0200 |
|---|---|---|
| committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-05-19 20:59:55 +0200 |
| commit | f97798e710929c0acb2b110c1cc16b1b267039a0 (patch) | |
| tree | 602a14310907efbc00098afbb0dd891ea3f410e9 | |
| parent | 318cd6fbde65ee5c7a4bd513d185fa57cc61c4cd (diff) | |
| download | plan9front-f97798e710929c0acb2b110c1cc16b1b267039a0.tar.xz | |
devsd: don't raise Enomem error if sdmalloc() fails, instead wait for the memory to become available
filesystems do not handle i/o errors well (cwfs will abandon the blocks),
and temporary exhaustion of kernel memory (because of too many i/o's in
parallel) causes read and write on the partition to fail.
i think it is better to wait for the memory to become available in
this case. the single allocation is at max SDmaxio bytes, which makes
it likely to become available. if we havnt even enought fo that, then
rebooting the machine would be the best option. (aux/reboot)
| -rw-r--r-- | sys/src/9/port/devsd.c | 20 | ||||
| -rw-r--r-- | sys/src/9/port/sdscsi.c | 3 |
2 files changed, 14 insertions, 9 deletions
diff --git a/sys/src/9/port/devsd.c b/sys/src/9/port/devsd.c index 0c53b6e47..38b9a4548 100644 --- a/sys/src/9/port/devsd.c +++ b/sys/src/9/port/devsd.c @@ -847,9 +847,12 @@ sdbio(Chan* c, int write, char* a, long len, uvlong off) b = (uchar*)a; allocd = 0; }else{ - b = sdmalloc(nb*unit->secsize); - if(b == nil) - error(Enomem); + while((b = sdmalloc(nb*unit->secsize)) == nil){ + if(!waserror()){ + tsleep(&up->sleep, return0, 0, 100); + poperror(); + } + } allocd = 1; } if(waserror()){ @@ -929,8 +932,12 @@ sdrio(SDreq* r, void* a, long n) } data = nil; - if(n > 0 && (data = sdmalloc(n)) == nil) - error(Enomem); + while(n > 0 && (data = sdmalloc(n)) == nil){ + if(!waserror()){ + tsleep(&up->sleep, return0, 0, 100); + poperror(); + } + } if(waserror()){ sdfree(data); r->data = nil; @@ -1484,8 +1491,7 @@ sdwrite(Chan* c, void* a, long n, vlong off) } if(n < 6 || n > sizeof(req->cmd)) error(Ebadarg); - if((req = malloc(sizeof(SDreq))) == nil) - error(Enomem); + req = smalloc(sizeof(SDreq)); req->unit = unit; if(waserror()){ free(req); diff --git a/sys/src/9/port/sdscsi.c b/sys/src/9/port/sdscsi.c index defad953e..e6b53c0b8 100644 --- a/sys/src/9/port/sdscsi.c +++ b/sys/src/9/port/sdscsi.c @@ -384,8 +384,7 @@ scsibio(SDunit* unit, int lun, int write, void* data, long nb, uvlong bno) SDreq *r; long rlen; - if((r = malloc(sizeof(SDreq))) == nil) - error(Enomem); + r = smalloc(sizeof(SDreq)); r->unit = unit; r->lun = lun; again: |
