diff options
author | Joonsoo Kim <iamjoonsoo.kim@lge.com> | 2014-04-03 17:47:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-03 19:20:59 -0400 |
commit | 9119a41e9091fb3a8204039d595bcdae24193c57 (patch) | |
tree | a4d8e613724f22581512820756f97048883f50fc /fs/hugetlbfs | |
parent | d26914d11751b23ca2e8747725f2cae10c2f2c1b (diff) |
mm, hugetlb: unify region structure handling
Currently, to track reserved and allocated regions, we use two different
ways, depending on the mapping. For MAP_SHARED, we use
address_mapping's private_list and, while for MAP_PRIVATE, we use a
resv_map.
Now, we are preparing to change a coarse grained lock which protect a
region structure to fine grained lock, and this difference hinder it.
So, before changing it, unify region structure handling, consistently
using a resv_map regardless of the kind of mapping.
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hugetlbfs')
-rw-r--r-- | fs/hugetlbfs/inode.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index d19b30ababf1..204027520937 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -366,7 +366,13 @@ static void truncate_hugepages(struct inode *inode, loff_t lstart) | |||
366 | 366 | ||
367 | static void hugetlbfs_evict_inode(struct inode *inode) | 367 | static void hugetlbfs_evict_inode(struct inode *inode) |
368 | { | 368 | { |
369 | struct resv_map *resv_map; | ||
370 | |||
369 | truncate_hugepages(inode, 0); | 371 | truncate_hugepages(inode, 0); |
372 | resv_map = (struct resv_map *)inode->i_mapping->private_data; | ||
373 | /* root inode doesn't have the resv_map, so we should check it */ | ||
374 | if (resv_map) | ||
375 | resv_map_release(&resv_map->refs); | ||
370 | clear_inode(inode); | 376 | clear_inode(inode); |
371 | } | 377 | } |
372 | 378 | ||
@@ -476,6 +482,11 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, | |||
476 | umode_t mode, dev_t dev) | 482 | umode_t mode, dev_t dev) |
477 | { | 483 | { |
478 | struct inode *inode; | 484 | struct inode *inode; |
485 | struct resv_map *resv_map; | ||
486 | |||
487 | resv_map = resv_map_alloc(); | ||
488 | if (!resv_map) | ||
489 | return NULL; | ||
479 | 490 | ||
480 | inode = new_inode(sb); | 491 | inode = new_inode(sb); |
481 | if (inode) { | 492 | if (inode) { |
@@ -487,7 +498,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, | |||
487 | inode->i_mapping->a_ops = &hugetlbfs_aops; | 498 | inode->i_mapping->a_ops = &hugetlbfs_aops; |
488 | inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; | 499 | inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; |
489 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 500 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
490 | INIT_LIST_HEAD(&inode->i_mapping->private_list); | 501 | inode->i_mapping->private_data = resv_map; |
491 | info = HUGETLBFS_I(inode); | 502 | info = HUGETLBFS_I(inode); |
492 | /* | 503 | /* |
493 | * The policy is initialized here even if we are creating a | 504 | * The policy is initialized here even if we are creating a |
@@ -517,7 +528,9 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, | |||
517 | break; | 528 | break; |
518 | } | 529 | } |
519 | lockdep_annotate_inode_mutex_key(inode); | 530 | lockdep_annotate_inode_mutex_key(inode); |
520 | } | 531 | } else |
532 | kref_put(&resv_map->refs, resv_map_release); | ||
533 | |||
521 | return inode; | 534 | return inode; |
522 | } | 535 | } |
523 | 536 | ||