- if (nbuf == 0)
- nbuf = atop(sane_size / 100); /* Get 1% of ram, but no more than we can map */
- if (nbuf > 8192)
- nbuf = 8192;
- if (nbuf < 256)
- nbuf = 256;
-
- if (niobuf == 0)
- niobuf = nbuf;
- if (niobuf > 4096)
- niobuf = 4096;
- if (niobuf < 128)
- niobuf = 128;
-
- size = (nbuf + niobuf) * sizeof(struct buf);
+ /* clip the number of buf headers upto 16k */
+ if (max_nbuf_headers == 0)
+ max_nbuf_headers = atop(sane_size / 50); /* Get 2% of ram, but no more than we can map */
+ if ((customnbuf == 0) && (max_nbuf_headers > 16384))
+ max_nbuf_headers = 16384;
+ if (max_nbuf_headers < CONFIG_MIN_NBUF)
+ max_nbuf_headers = CONFIG_MIN_NBUF;
+
+ /* clip the number of hash elements to 200000 */
+ if ( (customnbuf == 0 ) && nbuf_hashelements == 0) {
+ nbuf_hashelements = atop(sane_size / 50);
+ if (nbuf_hashelements > 200000)
+ nbuf_hashelements = 200000;
+ } else
+ nbuf_hashelements = max_nbuf_headers;
+
+ if (niobuf_headers == 0)
+ niobuf_headers = max_nbuf_headers;
+ if (niobuf_headers > 4096)
+ niobuf_headers = 4096;
+ if (niobuf_headers < CONFIG_MIN_NIOBUF)
+ niobuf_headers = CONFIG_MIN_NIOBUF;
+
+ size = (max_nbuf_headers + niobuf_headers) * sizeof(struct buf);