There is no need to keep 'npage' value inside our softc structure,
it is only used in one function. While doing so, change its type to vm_ooffset_t. We are still limited for swap-backed devices to 16TB on 32-bit architectures where PAGE_SIZE is 4096 bytes.
This commit is contained in:
parent
656628ee3b
commit
fcd57fbe6f
@ -178,7 +178,6 @@ struct md_s {
|
|||||||
|
|
||||||
/* MD_SWAP related fields */
|
/* MD_SWAP related fields */
|
||||||
vm_object_t object;
|
vm_object_t object;
|
||||||
unsigned npage;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mddestroy(struct md_s *sc, struct thread *td);
|
static int mddestroy(struct md_s *sc, struct thread *td);
|
||||||
@ -1002,8 +1001,9 @@ mddestroy(struct md_s *sc, struct thread *td)
|
|||||||
static int
|
static int
|
||||||
mdcreate_swap(struct md_ioctl *mdio, struct thread *td)
|
mdcreate_swap(struct md_ioctl *mdio, struct thread *td)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
struct md_s *sc;
|
struct md_s *sc;
|
||||||
|
vm_ooffset_t npage;
|
||||||
|
int error;
|
||||||
|
|
||||||
GIANT_REQUIRED;
|
GIANT_REQUIRED;
|
||||||
|
|
||||||
@ -1032,23 +1032,23 @@ mdcreate_swap(struct md_ioctl *mdio, struct thread *td)
|
|||||||
* Allocate an OBJT_SWAP object.
|
* Allocate an OBJT_SWAP object.
|
||||||
*
|
*
|
||||||
* sc_nsect is in units of DEV_BSIZE.
|
* sc_nsect is in units of DEV_BSIZE.
|
||||||
* sc_npage is in units of PAGE_SIZE.
|
* npage is in units of PAGE_SIZE.
|
||||||
*
|
*
|
||||||
* Note the truncation.
|
* Note the truncation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sc->secsize = DEV_BSIZE;
|
sc->secsize = DEV_BSIZE;
|
||||||
sc->npage = mdio->md_size / (PAGE_SIZE / DEV_BSIZE);
|
npage = mdio->md_size / (PAGE_SIZE / DEV_BSIZE);
|
||||||
sc->nsect = sc->npage * (PAGE_SIZE / DEV_BSIZE);
|
sc->nsect = npage * (PAGE_SIZE / DEV_BSIZE);
|
||||||
if (mdio->md_fwsectors != 0)
|
if (mdio->md_fwsectors != 0)
|
||||||
sc->fwsectors = mdio->md_fwsectors;
|
sc->fwsectors = mdio->md_fwsectors;
|
||||||
if (mdio->md_fwheads != 0)
|
if (mdio->md_fwheads != 0)
|
||||||
sc->fwheads = mdio->md_fwheads;
|
sc->fwheads = mdio->md_fwheads;
|
||||||
sc->object = vm_pager_allocate(OBJT_SWAP, NULL, PAGE_SIZE *
|
sc->object = vm_pager_allocate(OBJT_SWAP, NULL, PAGE_SIZE * npage,
|
||||||
(vm_offset_t)sc->npage, VM_PROT_DEFAULT, 0);
|
VM_PROT_DEFAULT, 0);
|
||||||
sc->flags = mdio->md_options & MD_FORCE;
|
sc->flags = mdio->md_options & MD_FORCE;
|
||||||
if (mdio->md_options & MD_RESERVE) {
|
if (mdio->md_options & MD_RESERVE) {
|
||||||
if (swap_pager_reserve(sc->object, 0, sc->npage) < 0) {
|
if (swap_pager_reserve(sc->object, 0, npage) < 0) {
|
||||||
vm_object_deallocate(sc->object);
|
vm_object_deallocate(sc->object);
|
||||||
sc->object = NULL;
|
sc->object = NULL;
|
||||||
mddestroy(sc, td);
|
mddestroy(sc, td);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user