public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dipankar Sarma <dipankar@in.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] files: doc update
Date: Fri, 24 Jun 2005 16:25:00 +0530	[thread overview]
Message-ID: <20050624105500.GF4804@in.ibm.com> (raw)
In-Reply-To: <20050624105410.GE4804@in.ibm.com>


Update files documentation to mention the need for reloading
fdtable pointer if ->file_lock is dropped.

Signed-off-by: Dipankar Sarma <dipankar@in.ibm.com>
---


 Documentation/filesystems/files.txt |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+)

diff -puN Documentation/filesystems/files.txt~files-doc-update Documentation/filesystems/files.txt
--- linux-2.6.12-mm1-fix/Documentation/filesystems/files.txt~files-doc-update	2005-06-26 06:01:40.000000000 +0530
+++ linux-2.6.12-mm1-fix-dipankar/Documentation/filesystems/files.txt	2005-06-26 06:13:09.000000000 +0530
@@ -101,3 +101,23 @@ the fdtable structure -
    API. If they are looked up lock-free, rcu_dereference()
    must be used. However it is advisable to use files_fdtable()
    and fcheck()/fcheck_files() which take care of these issues.
+
+7. While updating, the fdtable pointer must be looked up while
+   holding files->file_lock. If ->file_lock is dropped, then
+   another thread expand the files thereby creating a new
+   fdtable and making the earlier fdtable pointer stale.
+   For example :
+
+	spin_lock(&files->file_lock);
+	fd = locate_fd(files, file, start);
+	if (fd >= 0) {
+		/* locate_fd() may have expanded fdtable, load the ptr */
+		fdt = files_fdtable(files);
+		FD_SET(fd, fdt->open_fds);
+		FD_CLR(fd, fdt->close_on_exec);
+		spin_unlock(&files->file_lock);
+	.....
+
+   Since locate_fd() can drop ->file_lock (and reacquire ->file_lock),
+   the fdtable pointer (fdt) must be loaded after locate_fd().
+

_

  reply	other threads:[~2005-06-24 11:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-24 10:50 [PATCH 0/4] files: various updates Dipankar Sarma
2005-06-24 10:52 ` [PATCH 1/4] files: fix dupfd by fdt reload Dipankar Sarma
2005-06-24 10:53   ` [PATCH 2/4] files: fix expand_files return code Dipankar Sarma
2005-06-24 10:54     ` [PATCH 3/4] files: change fd_install assertion Dipankar Sarma
2005-06-24 10:55       ` Dipankar Sarma [this message]
2005-06-24 12:04       ` Artem B. Bityuckiy
2005-06-24 13:00         ` Dipankar Sarma
2005-06-24 13:55           ` Artem B. Bityuckiy
2005-06-24 14:09             ` Dipankar Sarma
2005-06-24 14:20               ` Artem B. Bityuckiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050624105500.GF4804@in.ibm.com \
    --to=dipankar@in.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox