Discussion:
P4 Clarifications - NEED ANSWERS
(too old to reply)
Daniel Ramsbrock
2005-11-28 16:47:45 UTC
Permalink
Here are the clarifications for which I still need answers. TA's, can
one of you respond? Thanks,

Daniel

1. Concurrency: Under 10.9: Issues, Dave Hovemeyer's Project 5
guidelines mention both concurrency and file sharing. We already know
that we don't have to worry about file sharing (more than one process
opening the same file). However, it is not quite clear whether we still
need to worry about concurrency. It seems not, since we are assuming
that only one process is accessing a file or directory at one time.
Additionally, VFS and the buffer cache have their own locking
mechanisms, so that should take care of our concurrency needs.
Basically, my question is: do we need to worry about locking anything,
either inside the Sys_ functions or the GOSFS_ functions?

2. Opening files: Do we create the file descriptor table entry in
Sys_Open or in GOSFS_Open? (same applies to Sys_OpenDirectory and
GOSFS_Open_Directory). It seems like we create it in Sys_Open since a
file needs an FD no matter from which filesystem it was opened.
Additionally, the semantics of the VFS Open() call suggest that we
should have an FD assigned (and therefore a File struct pointer ready)
before calling it. Where should the Malloc for that File struct occur?
It seems like it needs to happen inside our GOSFS_Open/OpenDirectory
function.

3. Opening directories: Is there any fundamental difference between
Sys_Open and Sys_OpenDirectory? It seems like you can use basically the
same code for both, with the exception of the mode parameter and the
different names for the VFS functions which it needs to call. Are there
any other things which distinguish them?

4. Creating directories: When we create a new directory, we immediately
allocate a new blank block for it, correct? Unlike files, directories
will only ever consist of one block, so we can go ahead and allocate it
right away (whereas with a file, you wait to create a block until the
first data is written).

5. Allocation: In general, should we be zeroing out newly allocated disk
blocks as part of our allocation function? Or is this a policy decision
which we can make on our own?

6. Allocation: Should we sync the superblock eagerly after an update to
the free block bitmap (i.e. a block was either allocated or
deallocated)? This could result in a lot of disk writes, but this may be
a good tradeoff since the information in that bitmap is crucial to the
file system. If it gets corrupted, lots of data could be lost.
Iulian Neamtiu
2005-11-28 18:44:18 UTC
Permalink
Post by Daniel Ramsbrock
Here are the clarifications for which I still need answers. TA's, can
one of you respond? Thanks,
Daniel
1. Concurrency: Under 10.9: Issues, Dave Hovemeyer's Project 5
guidelines mention both concurrency and file sharing. We already know
that we don't have to worry about file sharing (more than one process
opening the same file). However, it is not quite clear whether we still
need to worry about concurrency. It seems not, since we are assuming
that only one process is accessing a file or directory at one time.
Additionally, VFS and the buffer cache have their own locking
mechanisms, so that should take care of our concurrency needs.
Basically, my question is: do we need to worry about locking anything,
either inside the Sys_ functions or the GOSFS_ functions?
I can't answer that question, you go figure it out. Our test procedure is
laid out in the grading criteria.
Post by Daniel Ramsbrock
2. Opening files: Do we create the file descriptor table entry in
Sys_Open or in GOSFS_Open? (same applies to Sys_OpenDirectory and
GOSFS_Open_Directory). It seems like we create it in Sys_Open since a
file needs an FD no matter from which filesystem it was opened.
Additionally, the semantics of the VFS Open() call suggest that we
should have an FD assigned (and therefore a File struct pointer ready)
before calling it. Where should the Malloc for that File struct occur?
It seems like it needs to happen inside our GOSFS_Open/OpenDirectory
function.
Sys_Open
Post by Daniel Ramsbrock
3. Opening directories: Is there any fundamental difference between
Sys_Open and Sys_OpenDirectory? It seems like you can use basically the
same code for both, with the exception of the mode parameter and the
different names for the VFS functions which it needs to call. Are there
any other things which distinguish them?
They're similar except for 'mode', that's right.
Post by Daniel Ramsbrock
4. Creating directories: When we create a new directory, we immediately
allocate a new blank block for it, correct? Unlike files, directories
will only ever consist of one block, so we can go ahead and allocate it
right away (whereas with a file, you wait to create a block until the
first data is written).
That's up to you. Although it makes sense to allocate the block only when
you need to create an entry in that directory (if ever), go ahead and
allocate the block right upon create dir if that's easier for you.
Post by Daniel Ramsbrock
5. Allocation: In general, should we be zeroing out newly allocated disk
blocks as part of our allocation function? Or is this a policy decision
which we can make on our own?
You should. Think about what happens when the buffer given to you by the
buffer cache contained parts of a sensitive file; it gets recycled by the
buffer cache and suddenly you can sync() that buffer and reveal the
(partial) content of the sensitive file.
Post by Daniel Ramsbrock
6. Allocation: Should we sync the superblock eagerly after an update to
the free block bitmap (i.e. a block was either allocated or
deallocated)? This could result in a lot of disk writes, but this may be
a good tradeoff since the information in that bitmap is crucial to the
file system. If it gets corrupted, lots of data could be lost.
That's up to you. Sync()ing often is certainly not a bad idea in the real
world where power losses are common, but it's not necessary for P5.
As you can see in the grading criteria, before
powering Bochs down (for the persistence test) write.exe issues a Sync().

Iulian
Daniel Ramsbrock
2005-11-28 19:18:11 UTC
Permalink
I guess I should have split this one up since it was really two separate
questions.

1. Where do we create the FD entry (i.e. mark that slot as used and
determine which FD number to return)?
2. Where do we Malloc the File struct to which that entry points?

I'm guessing that your answer (Sys_Open) was to 1. What's the answer to
2.--inside the GOSFS_Open/OpenDirectory function?

Thanks,

Daniel
Post by Daniel Ramsbrock
Post by Daniel Ramsbrock
2. Opening files: Do we create the file descriptor table entry in
Sys_Open or in GOSFS_Open? (same applies to Sys_OpenDirectory and
GOSFS_Open_Directory). It seems like we create it in Sys_Open since a
file needs an FD no matter from which filesystem it was opened.
Additionally, the semantics of the VFS Open() call suggest that we
should have an FD assigned (and therefore a File struct pointer ready)
before calling it. Where should the Malloc for that File struct occur?
It seems like it needs to happen inside our GOSFS_Open/OpenDirectory
function.
Sys_Open
Iulian Neamtiu
2005-11-29 03:22:39 UTC
Permalink
Post by Daniel Ramsbrock
1. Where do we create the FD entry (i.e. mark that slot as used and
determine which FD number to return)?
2. Where do we Malloc the File struct to which that entry points?
I'm guessing that your answer (Sys_Open) was to 1.
Yes.

What's the answer to
Post by Daniel Ramsbrock
2.--inside the GOSFS_Open/OpenDirectory function?
Yes. Actually you don't have to call Malloc(), since you have an
Allocate_File() in vfs.c, right ?


Iulian

Loading...