hugetlb: move inode attributes into hugetlb_key
PATCH 9/11 hugetlb: move inode attributes into hugetlb_key
This patch moves uid/gid/mode/size fields used in struct inode and the checks on them into key management code and structures.
hugetlbpage.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-)
arch/i386/mm/hugetlbpage.c +14 -6
@@ -33,6 +33,10 @@ struct hugetlb_key {struct inode *in;int key;int busy; +uid_t uid; +gid_t gid; +umode_t mode; +loff_t size; };static struct hugetlb_key htlbpagek[MAX_ID ];
@@ -63,7 +67,7 @@ static struct hugetlb_key *find_key(intreturn NULL ; } -static int check_size_prot (struct inode *inode,unsigned long len,int prot,int flag); +static int check_size_prot (struct hugetlb_key *key,unsigned long len,int prot,int flag);/* * Call without htlbpage_lock, returns with htlbpage_lock held. */
@@ -105,6 +109,10 @@ struct hugetlb_key *alloc_key(int key, u inode->i_gid = current->fsgid; inode->i_mode = prot; inode->i_size = len; + hugetlb_key->uid = current->fsuid; + hugetlb_key->gid = current->fsgid; + hugetlb_key->mode = prot; + hugetlb_key->size = len; *new =1 ; } }
@@ -112,7 +120,7 @@ struct hugetlb_key *alloc_key(int key, u }else if (key_busy (hugetlb_key)) { hugetlb_key =ERR_PTR (-EAGAIN );spin_unlock (&htlbpage_lock); - }else if (check_size_prot (hugetlb_key->in, len, prot, flag) <0 ) { + }else if (check_size_prot (hugetlb_key, len, prot, flag) <0 ) {kfree (hugetlb_key->in); hugetlb_key->key =0 ; hugetlb_key =ERR_PTR (-EINVAL );
@@ -360,13 +368,13 @@ void zap_hugepage_range(struct vm_area_sspin_unlock (&mm->page_table_lock); } -static int check_size_prot (struct inode *inode,unsigned long len,int prot,int flag) +static int check_size_prot (struct hugetlb_key *key,unsigned long len,int prot,int flag) { -if (inode->i_uid != current->fsuid) +if (key->uid != current->fsuid)return -1 ; -if (inode->i_gid != current->fsgid) +if (key->gid != current->fsgid)return -1 ; -if (inode->i_size != len) +if (key->size != len)return -1 ;return 0 ; }