net: Kill ether_table[] declaration.
[linux-2.6-block.git] / mm / shmem.c
index 9e755c166cc5c67a315f4c9d55eff5087a55511d..ba4ad28b7db6b81c141915a5d3eb4241fdbfd1a7 100644 (file)
@@ -916,11 +916,12 @@ static int shmem_unuse_inode(struct shmem_inode_info *info, swp_entry_t entry, s
                        if (size > ENTRIES_PER_PAGE)
                                size = ENTRIES_PER_PAGE;
                        offset = shmem_find_swp(entry, ptr, ptr+size);
+                       shmem_swp_unmap(ptr);
                        if (offset >= 0) {
                                shmem_dir_unmap(dir);
+                               ptr = shmem_swp_map(subdir);
                                goto found;
                        }
-                       shmem_swp_unmap(ptr);
                }
        }
 lost1:
@@ -1037,7 +1038,6 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
        struct address_space *mapping;
        unsigned long index;
        struct inode *inode;
-       bool unlock_mutex = false;
 
        BUG_ON(!PageLocked(page));
        mapping = page->mapping;
@@ -1072,15 +1072,14 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
         * we've taken the spinlock, because shmem_unuse_inode() will
         * prune a !swapped inode from the swaplist under both locks.
         */
-       if (swap.val && list_empty(&info->swaplist)) {
+       if (swap.val) {
                mutex_lock(&shmem_swaplist_mutex);
-               /* move instead of add in case we're racing */
-               list_move_tail(&info->swaplist, &shmem_swaplist);
-               unlock_mutex = true;
+               if (list_empty(&info->swaplist))
+                       list_add_tail(&info->swaplist, &shmem_swaplist);
        }
 
        spin_lock(&info->lock);
-       if (unlock_mutex)
+       if (swap.val)
                mutex_unlock(&shmem_swaplist_mutex);
 
        if (index >= info->next_index) {