Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/include
In directory usw-pr-cvs1:/tmp/cvs-serv10543
Modified Files:
bitmap.h mft.h ntfsd.h volume.h
Log Message:
Ok, ntfsd was a mistake for userspace. It increases complexity no end while
not giving us much functionality. Lets get it working and then worry about the
kernel. - As it was the idea originally anyway, so this is just a return on the
right track. (-8
We keep the timer and signal handler but the only thing we do is to set a bool
flag (ntfs_need_sync) and we will just check this in appropriate places and
if it is true we call ntfs_sync_volumes() which sets it back to false. This
means no more locking at all of any description and no need to worry about the
signal handler interrupting things in bad ways and/or at bad times in the main
code.
Index: bitmap.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/bitmap.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- bitmap.h 2001/04/08 03:02:55 1.5
+++ bitmap.h 2001/04/10 22:20:19 1.6
@@ -49,5 +49,5 @@
/**
- * get_bit - get value of a bit in a field of bits
+ * ntfs_get_bit - get value of a bit in a field of bits
* @bitmap: field of bits
* @bit: bit to get
@@ -59,5 +59,5 @@
/**
- * get_and_set_bit - get value of a bit in a field of bits and set it
+ * ntfs_get_and_set_bit - get value of a bit in a field of bits and set it
* @bitmap: field of bits
* @bit: bit to get/set
Index: mft.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/mft.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -U2 -r1.17 -r1.18
--- mft.h 2001/04/09 00:05:37 1.17
+++ mft.h 2001/04/10 22:20:19 1.18
@@ -29,7 +29,6 @@
#endif
-#include <asm/atomic.h>
-#include <linux/spinlock.h>
#include <linux/list.h>
+#include <linux/bitops.h>
#include "endians.h"
@@ -296,7 +295,5 @@
* nr_dirty_mft_entries: Number of dirty mft_entries.
*
- * dirty_mft_entries_lock: Spinlock to serialize access to
- * {nr_}dirty_mft_entries.
- *
+ *
* The mft_entry struct.
* ---------------------
@@ -308,8 +305,4 @@
* set.)
*
- * m_rec_lock: Spinlock controlling access to m_rec. Only one
- * writer at a time (and no readers while one writer) as the mft
- * record will be corrupt during the write process.
- *
* m_flags: Atomic flags describing the mft entry / record:
*
@@ -327,10 +320,8 @@
* includes the sequence number for consistency checking purposes.)
*
- * m_count: Atomic usage count. When zero this record is not referenced by
+ * m_count: Usage count. When zero this record is not referenced by
* any files and can be thrown away safely (writing it to disk
* first if dirty flag is set).
*
- * m_lock: Lock controlling access to this entry.
- *
* m_list: Anchor for the mft_entries linked list.
*
@@ -349,5 +340,4 @@
* we are talking about, possibly which mft record it is in (+ position
* in attribute list?) and a pointer to the attribute value itself.
- * - Add aging for mft_entries.
*
* The ntfs_file struct (file = base mft record).
@@ -375,5 +365,5 @@
* a possible nr_m_entries, but refs is shorter to write. (-;
*
- * f_count: Atomic usage count. When zero this file is not open by anyone
+ * f_count: Usage count. When zero this file is not open by anyone
* and can be thrown away safely. No need to concern oneself with
* dirty state as this is done on a mft_entry level, i.e. one level
@@ -411,10 +401,8 @@
typedef struct {
MFT_RECORD *m_rec;
- struct spinlock_t m_rec_lock;
unsigned int m_flags;
MFT_REFERENCE m_ref;
- atomic_t m_count;
+ unsigned int m_count;
ntfs_file *m_file;
- struct spinlock_t m_lock;
struct list_head m_list;
struct list_head m_dirty_list;
@@ -426,5 +414,5 @@
mft_entry *m_entries;
int nr_m_refs;
- atomic_t f_count;
+ int f_count;
struct list_head f_list;
ntfs_volume *f_vol;
@@ -438,12 +426,7 @@
* removed from the dirty list of the volume (if it is on the list).
*
- * This function must be called with the volume's dirty_mft_entries_lock held,
- * if the entry is on the volume's mft_entries_dirty list. If it is not, the
- * lock doesn't need to be held.
- *
* Return 0 on success and -ERRNO on error. Following failure return values
* are defined:
* -EBADF Mft_entry is corrupt (error flag set).
- * -EDEADLK Couldn't acquire a necessary lock.
* -EIO Writing to disk failed.
* -ENOTSUP Tried to write to a sparse mft record. Should never
@@ -523,5 +506,4 @@
*
* Following failure return values are defined:
- * -EDEADLK Couldn't acquire a necessary lock.
* -EIO Reading from disk failed (or mst error detected). Error
* flag has been set.
@@ -548,5 +530,5 @@
static __inline__ int map_mft_entry(mft_entry *me)
{
- atomic_inc(&me->m_count);
+ me->m_count++;
if (MftEntryMapped(me))
return 0;
@@ -565,6 +547,6 @@
static __inline__ void unmap_mft_entry(mft_entry *me)
{
- if (MftEntryMapped(me) && atomic_read(&me->m_count) > 0)
- atomic_dec(&me->m_count);
+ if (MftEntryMapped(me) && me->m_count > 0)
+ me->m_count--;
}
@@ -578,5 +560,4 @@
* are returned:
* -EBUSY Use count is above zero or couldn't sync dirty entry.
- * -EDEADLK Failed to acquire a necessary lock.
* others Values returned by flush_mft_entry().
*/
@@ -600,5 +581,4 @@
* Return 0 on success and -ERRNO on error. On error, the following values are
* returned:
- * -EDEADLK Failed to acquire a necessary lock.
* -EEXIST Entry alread exists in the volume. There must be a bug
* somewhere. This should _really_ never happen.
@@ -619,5 +599,4 @@
* Return 0 on success and -ERRNO on error. The defined error codes are:
* -EBUSY The use count of the entry is above 0.
- * -EDEADLK Failed to acquire a necessary lock.
* others Values returned by flush_mft_entry.
*/
Index: ntfsd.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/ntfsd.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- ntfsd.h 2001/04/07 17:30:10 1.5
+++ ntfsd.h 2001/04/10 22:20:19 1.6
@@ -26,7 +26,5 @@
#include <linux/bitops.h>
-#include <linux/spinlock.h>
#include <linux/list.h>
-#include <asm/atomic.h>
#include "volume.h"
@@ -39,38 +37,18 @@
extern struct listhead ntfs_mounted_volumes;
extern int nr_ntfs_mounted_volumes;
-extern spinlock_t ntfs_mounted_volumes_lock;
/*
- * We use a set of atomic flags for locking / access serialization. No need of
- * any additional locking (using spinlocks/semaphores/whatever) due to
- * atomicity of operations.
+ * Set to true by the 5 second timer handler and set to false by
+ * ntfs_sync_volumes() which we call when we detect this to be true.
*/
-extern unsigned int ntfsd_flags;
+extern BOOL ntfs_need_sync;
-/* Ntfsd flags bit values */
-#define NTFSD_running 0
-#define NTFSD_busy 1
-#define NTFSD_started 2
- /* bits 3-31 reserved for future use */
-
-#define NtfsdRunning(a) test_bit(NTFSD_running, &(a))
-#define SetNtfsdRunning(a) set_bit(NTFSD_running, &(a))
-#define ClearNtfsdRunning(a) clear_bit(NTFSD_running, &(a))
-
-#define NtfsdBusy(a) test_bit(NTFSD_busy, &(a))
-#define SetNtfsdBusy(a) set_bit(NTFSD_busy, &(a))
-#define ClearNtfsdBusy(a) clear_bit(NTFSD_busy, &(a))
-
-#define NtfsdStarted(a) test_bit(NTFSD_started, &(a))
-#define SetNtfsdStarted(a) set_bit(NTFSD_started, &(a))
-#define ClearNtfsdStarted(a) clear_bit(NTFSD_started, &(a))
-
/**
- * ntfsd_start - start the writer daemon/thread
+ * ntfs_timer_start - start the 5 second timer setting ntfs_need_sync to true
*
- * Start the writer daemon / thread. Currently implemented using an interval
- * timer and a handler for the SIGALRM signal. This function can and should be
- * called whenever you mount a volume, so that we know how many times you need
- * to call ntfs_stop() before we actually stop the writer.
+ * Start the interval timer and setup a handler for the SIGALRM signal. This
+ * function can and should be called whenever volume is mounted, so that we
+ * know how many times you need to call ntfs_timer_stop() before we actually
+ * stop the timer.
*
* Return TRUE on success or FALSE on error. In the latter case, errno contains
@@ -82,43 +60,38 @@
* ntfsd will handle SIGALRM should it occur, but it won't do
* anything as it is not started.
- * EBUSY - Ntfsd is busy in a previous call to ntfsd_start/ntfsd_stop.
- * Try calling again later.
* EINTR - One of the system calls was interrupted more than three times
* in a row. You could try again.
* ENOTSUP - The host system does not support SIGALRM signal. )-:
* EFAULT - Internal error. This is BAD.
- * EMFILE - Ntfsd has been started too many times already. Cannot start
- * again before at least one ntfsd_stop() call is issued.
+ * EMFILE - Times has been started too many times already. Cannot start
+ * again before at least one ntfs_timer_stop() call is issued.
* others - Other error codes returned by one of the system calls.
*/
-BOOL ntfsd_start(void);
+BOOL ntfs_timer_start(void);
/**
- * ntfsd_stop - stop the writer daemon/thread
+ * ntfs_timer_start - stop the 5 second timer
*
- * Stop the writer daemon / thread. Currently implemented using an interval
- * timer and a handler for the SIGALRM signal. This functions should be called
- * once for every umount performed. The daemon will only be stopped if
- * ntfsd_stop() has been called the same number of times as ntfsd_start(), i.e.
- * for every call to ntfsd_start(), you need to issue a corresponding
- * ntfsd_stop().
+ * Stop the interval timer and remove the handler for the SIGALRM signal.
+ * This function should be called once for every umount performed. The daemon
+ * will only be stopped if ntfs_timer_stop() has been called the same number of
+ * times as ntfs_timer_start(), i.e. for every call to ntfs_timer_start(), you
+ * need to issue a corresponding ntfs_timer_stop().
*
* Return TRUE on success or FALSE on error. In the latter case, errno contains
* the error code.
*
- * On error, ntfsd remains active, unless errno is ECANCELED, in which case
- * ntfsd has been stopped (and the timer has been stopped, so no periodic
- * SIGALRM signals will be generated), but ntfsd is still registered as the
- * SIGALRM handler (since uninstallation failed), so the code has to remain
- * loaded in memory. In theory this will never occur but better catch the
- * impossible before practise makes the the theoretically impossible possible.
+ * On error, the handler remains active, unless errno is ECANCELED, in which
+ * case the timer has been stopped, so no periodic SIGALRM signals will be
+ * generated), but the SIGALRM handler is still registered (since
+ * uninstallation failed), so the code has to remain loaded in memory. In
+ * theory this will never occur but better catch the impossible before practise
+ * makes the the theoretically impossible possible.
*
* Important error codes:
* ECANCELED - The timer was stopped but the signal handler could not be
* reset. Tried restarting the timer but this failed. So,
- * ntfsd will handle SIGALRM should it occur, but it won't do
- * anything as it is not started any more.
- * EBUSY - Ntfsd is busy in a previous call to ntfsd_start/ntfsd_stop.
- * Try calling again later.
+ * we will handle SIGALRM should it occur, but we won't do
+ * anything as we are not started any more.
* EINTR - One of the system calls was interrupted more than three times
* in a row. You could try again.
@@ -127,5 +100,5 @@
* others - Other error codes returned by one of the system calls.
*/
-BOOL ntfsd_stop(void);
+BOOL ntfs_timer_stop(void);
#endif /* defined NTFSD_H */
Index: volume.h
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/include/volume.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -U2 -r1.10 -r1.11
--- volume.h 2001/04/09 00:05:37 1.10
+++ volume.h 2001/04/10 22:20:19 1.11
@@ -26,6 +26,4 @@
#include <stdio.h>
-#include <asm/atomic.h>
-#include <linux/spinlock.h>
#include <linux/list.h>
@@ -34,12 +32,4 @@
/*
- * FIXME: We should have a volume lock at some point (possibly a spinlock?) for
- * the volume structure also a lock for major modifications, much like the big
- * kernel lock. These two locks could be one and the same. Later on, we in
- * addition, will need finer grained locks to lock individual structures and
- * structure elements like the lcn_bitmap, mft_bitmap, etc. These locks will
- * need to protect operations like changing a directory, a mft record, etc.
- */
-/*
* FIXME: Do we really want to return a pointer to the actual volume structure
* to the user to play with? It would be better to completely abstract the
@@ -122,6 +112,4 @@
records which are dirty. */
int nr_dirty_mft_entries; /* Number of dirty mft_entries. */
- spinlock_t dirty_mft_entries_lock; /* Spinlock to serialize access to
- {nr_}dirty_mft_entries. */
struct list_head v_list; /* Anchor for list of all mounted
volumes. */
|