]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - include/linux/blkdev.h
block: Consolidate command flag and queue limit checks for merges
[mirror_ubuntu-zesty-kernel.git] / include / linux / blkdev.h
index 3a6fea7460f1f0309508432696609e3376b2195d..90f7abe8f183a1c2ae616931714b878127e4d1bf 100644 (file)
@@ -605,6 +605,18 @@ static inline bool rq_mergeable(struct request *rq)
        return true;
 }
 
+static inline bool blk_check_merge_flags(unsigned int flags1,
+                                        unsigned int flags2)
+{
+       if ((flags1 & REQ_DISCARD) != (flags2 & REQ_DISCARD))
+               return false;
+
+       if ((flags1 & REQ_SECURE) != (flags2 & REQ_SECURE))
+               return false;
+
+       return true;
+}
+
 /*
  * q->prep_rq_fn return values
  */
@@ -800,6 +812,25 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
        return blk_rq_cur_bytes(rq) >> 9;
 }
 
+static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
+                                                    unsigned int cmd_flags)
+{
+       if (unlikely(cmd_flags & REQ_DISCARD))
+               return q->limits.max_discard_sectors;
+
+       return q->limits.max_sectors;
+}
+
+static inline unsigned int blk_rq_get_max_sectors(struct request *rq)
+{
+       struct request_queue *q = rq->q;
+
+       if (unlikely(rq->cmd_type == REQ_TYPE_BLOCK_PC))
+               return q->limits.max_hw_sectors;
+
+       return blk_queue_get_max_sectors(q, rq->cmd_flags);
+}
+
 /*
  * Request issue related functions.
  */