2002-01-31 01:03:38

by Ulrich Weigand

[permalink] [raw]
Subject: [email protected]

Momchil Velikov wrote:

+int move_from_swap_cache(struct page *page, unsigned long index,
+ struct address_space *mapping)
+{
+ void **pslot;
+ int err;
+
+ if (!PageLocked(page))
+ BUG();
+
+ spin_lock(&swapper_space.i_shared_lock);
+ spin_lock(&mapping->i_shared_lock);
+
+ err = radix_tree_reserve(&mapping->page_tree, index, &pslot);
+ if (!err) {
+ swp_entry_t entry;
+
+ block_flushpage(page, 0);
+ entry.val = page->index;
+ __delete_from_swap_cache(page);
+ swap_free(entry);
+
+ *pslot = page;
+ page->flags = ((page->flags & ~(1 << PG_uptodate | 1 << PG_error
+ | 1 << PG_referenced | 1 << PG_arch_1
+ | 1 << PG_checked))
+ | (1 << PG_dirty));
+ page->index = index;
+ add_page_to_inode_queue (mapping, page);
+ atomic_inc(&page_cache_size);
+ }
+
+ spin_lock(&mapping->i_shared_lock);
+ spin_lock(&swapper_space.i_shared_lock);

Don't you mean spin_unlock here?

Bye,
Ulrich

--
Dr. Ulrich Weigand
[email protected]


2002-01-31 01:18:48

by Andrew Morton

[permalink] [raw]
Subject: Re: [email protected]

Ulrich Weigand wrote:
>
> Momchil Velikov wrote:
>
> +int move_from_swap_cache(struct page *page, unsigned long index,
> + struct address_space *mapping)
> +{
> + void **pslot;
> + int err;
> +
> + if (!PageLocked(page))
> + BUG();
> +
> + spin_lock(&swapper_space.i_shared_lock);
> + spin_lock(&mapping->i_shared_lock);
> +
> + err = radix_tree_reserve(&mapping->page_tree, index, &pslot);
> + if (!err) {
> + swp_entry_t entry;
> +
> + block_flushpage(page, 0);

block_flushpage inside spinlock is a no-no. It does I/O,
and sleeps.

-