NFSv4.2: Update mode bits after ALLOCATE and DEALLOCATE
[linux-block.git] / fs / nfs / internal.h
index 8f8cd6e2d4dbcb83223cc95d575daf652a056836..3160676364348db1e58a666fd50273f48197711f 100644 (file)
@@ -604,6 +604,31 @@ static inline gfp_t nfs_io_gfp_mask(void)
        return GFP_KERNEL;
 }
 
+/*
+ * Special version of should_remove_suid() that ignores capabilities.
+ */
+static inline int nfs_should_remove_suid(const struct inode *inode)
+{
+       umode_t mode = inode->i_mode;
+       int kill = 0;
+
+       /* suid always must be killed */
+       if (unlikely(mode & S_ISUID))
+               kill = ATTR_KILL_SUID;
+
+       /*
+        * sgid without any exec bits is just a mandatory locking mark; leave
+        * it alone.  If some exec bits are set, it's a real sgid; kill it.
+        */
+       if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
+               kill |= ATTR_KILL_SGID;
+
+       if (unlikely(kill && S_ISREG(mode)))
+               return kill;
+
+       return 0;
+}
+
 /* unlink.c */
 extern struct rpc_task *
 nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
@@ -704,6 +729,24 @@ unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp)
        return nfs_block_bits(bsize, nrbitsp);
 }
 
+/*
+ * Compute and set NFS server rsize / wsize
+ */
+static inline
+unsigned long nfs_io_size(unsigned long iosize, enum xprt_transports proto)
+{
+       if (iosize < NFS_MIN_FILE_IO_SIZE)
+               iosize = NFS_DEF_FILE_IO_SIZE;
+       else if (iosize >= NFS_MAX_FILE_IO_SIZE)
+               iosize = NFS_MAX_FILE_IO_SIZE;
+       else
+               iosize = iosize & PAGE_MASK;
+
+       if (proto == XPRT_TRANSPORT_UDP)
+               return nfs_block_bits(iosize, NULL);
+       return iosize;
+}
+
 /*
  * Determine the maximum file size for a superblock
  */
@@ -859,3 +902,36 @@ static inline void nfs_set_port(struct sockaddr *sap, int *port,
 
        rpc_set_port(sap, *port);
 }
+
+struct nfs_direct_req {
+       struct kref             kref;           /* release manager */
+
+       /* I/O parameters */
+       struct nfs_open_context *ctx;           /* file open context info */
+       struct nfs_lock_context *l_ctx;         /* Lock context info */
+       struct kiocb *          iocb;           /* controlling i/o request */
+       struct inode *          inode;          /* target file of i/o */
+
+       /* completion state */
+       atomic_t                io_count;       /* i/os we're waiting for */
+       spinlock_t              lock;           /* protect completion state */
+
+       loff_t                  io_start;       /* Start offset for I/O */
+       ssize_t                 count,          /* bytes actually processed */
+                               max_count,      /* max expected count */
+                               bytes_left,     /* bytes left to be sent */
+                               error;          /* any reported error */
+       struct completion       completion;     /* wait for i/o completion */
+
+       /* commit state */
+       struct nfs_mds_commit_info mds_cinfo;   /* Storage for cinfo */
+       struct pnfs_ds_commit_info ds_cinfo;    /* Storage for cinfo */
+       struct work_struct      work;
+       int                     flags;
+       /* for write */
+#define NFS_ODIRECT_DO_COMMIT          (1)     /* an unstable reply was received */
+#define NFS_ODIRECT_RESCHED_WRITES     (2)     /* write verification failed */
+       /* for read */
+#define NFS_ODIRECT_SHOULD_DIRTY       (3)     /* dirty user-space page after read */
+#define NFS_ODIRECT_DONE               INT_MAX /* write verification failed */
+};