From 0f40a399103893c73274af1b7a5e8ddafc71d963 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Fri, 31 Mar 1995 18:43:23 +0000 Subject: (diskfs_truncate): Don't acquire writer lock on NP->dn->allocptrlock until after forcing delayed copies through; otherwise the pageins will deadlock attempting to get a reader lock to service them. This is safe, because we only need NP->allocsize here, and that can't change as long as we hold NP->lock. --- ufs/sizes.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ufs/sizes.c b/ufs/sizes.c index bf9e2c38..ef7666b1 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -1,5 +1,5 @@ /* File growth and truncation - Copyright (C) 1993, 1994 Free Software Foundation + Copyright (C) 1993, 1994, 1995 Free Software Foundation This file is part of the GNU Hurd. @@ -83,13 +83,11 @@ diskfs_truncate (struct node *np, diskfs_file_update (np, 1); } - rwlock_writer_lock (&np->dn->allocptrlock); - /* Now flush all the data past the new size from the kernel. Also force any delayed copies of this data to take place - immediately. (We are changing the data implicitly to zeros - and doing it without the kernels immediate knowledge; - this forces us to help out the kernel thusly.) */ + immediately. (We are implicitly changing the data to zeros + and doing it without the kernel's immediate knowledge; + accordingl we must help out the kernel thusly.) */ spin_lock (&node2pagelock); upi = np->dn->fileinfo; if (upi) @@ -110,6 +108,8 @@ diskfs_truncate (struct node *np, pager_unreference (upi->p); } + rwlock_writer_lock (&np->dn->allocptrlock); + /* Update the size on disk; fsck will finish freeing blocks if necessary should we crash. */ np->dn_stat.st_size = length; -- cgit v1.2.3