Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.dk/linux-block

Pull xen block driver fixes from Jens Axboe:
"A few small bug fixes for xen-blk{front,back} that have been sitting
over my vacation"

* 'for-linus' of git://git.kernel.dk/linux-block:
xen-blkback: replace work_pending with work_busy in purge_persistent_gnt()
xen-blkfront: don't add indirect pages to list when !feature_persistent
xen-blkfront: introduce blkfront_gather_backend_features()

+74 -58
+2 -2
drivers/block/xen-blkback/blkback.c
··· 369 369 return; 370 370 } 371 371 372 - if (work_pending(&blkif->persistent_purge_work)) { 373 - pr_alert_ratelimited("Scheduled work from previous purge is still pending, cannot purge list\n"); 372 + if (work_busy(&blkif->persistent_purge_work)) { 373 + pr_alert_ratelimited("Scheduled work from previous purge is still busy, cannot purge list\n"); 374 374 return; 375 375 } 376 376
+72 -56
drivers/block/xen-blkfront.c
··· 179 179 ((_segs + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME) 180 180 181 181 static int blkfront_setup_indirect(struct blkfront_info *info); 182 + static int blkfront_gather_backend_features(struct blkfront_info *info); 182 183 183 184 static int get_id_from_freelist(struct blkfront_info *info) 184 185 { ··· 1129 1128 * Add the used indirect page back to the list of 1130 1129 * available pages for indirect grefs. 1131 1130 */ 1132 - indirect_page = pfn_to_page(s->indirect_grants[i]->pfn); 1133 - list_add(&indirect_page->lru, &info->indirect_pages); 1131 + if (!info->feature_persistent) { 1132 + indirect_page = pfn_to_page(s->indirect_grants[i]->pfn); 1133 + list_add(&indirect_page->lru, &info->indirect_pages); 1134 + } 1134 1135 s->indirect_grants[i]->gref = GRANT_INVALID_REF; 1135 1136 list_add_tail(&s->indirect_grants[i]->node, &info->grants); 1136 1137 } ··· 1522 1519 info->shadow_free = info->ring.req_prod_pvt; 1523 1520 info->shadow[BLK_RING_SIZE(info)-1].req.u.rw.id = 0x0fffffff; 1524 1521 1525 - rc = blkfront_setup_indirect(info); 1522 + rc = blkfront_gather_backend_features(info); 1526 1523 if (rc) { 1527 1524 kfree(copy); 1528 1525 return rc; ··· 1723 1720 1724 1721 static int blkfront_setup_indirect(struct blkfront_info *info) 1725 1722 { 1726 - unsigned int indirect_segments, segs; 1723 + unsigned int segs; 1727 1724 int err, i; 1728 1725 1729 - err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1730 - "feature-max-indirect-segments", "%u", &indirect_segments, 1731 - NULL); 1732 - if (err) { 1733 - info->max_indirect_segments = 0; 1726 + if (info->max_indirect_segments == 0) 1734 1727 segs = BLKIF_MAX_SEGMENTS_PER_REQUEST; 1735 - } else { 1736 - info->max_indirect_segments = min(indirect_segments, 1737 - xen_blkif_max_segments); 1728 + else 1738 1729 segs = info->max_indirect_segments; 1739 - } 1740 1730 1741 1731 err = fill_grant_buffer(info, (segs + INDIRECT_GREFS(segs)) * BLK_RING_SIZE(info)); 1742 1732 if (err) ··· 1793 1797 } 1794 1798 1795 1799 /* 1800 + * Gather all backend feature-* 1801 + */ 1802 + static int blkfront_gather_backend_features(struct blkfront_info *info) 1803 + { 1804 + int err; 1805 + int barrier, flush, discard, persistent; 1806 + unsigned int indirect_segments; 1807 + 1808 + info->feature_flush = 0; 1809 + 1810 + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1811 + "feature-barrier", "%d", &barrier, 1812 + NULL); 1813 + 1814 + /* 1815 + * If there's no "feature-barrier" defined, then it means 1816 + * we're dealing with a very old backend which writes 1817 + * synchronously; nothing to do. 1818 + * 1819 + * If there are barriers, then we use flush. 1820 + */ 1821 + if (!err && barrier) 1822 + info->feature_flush = REQ_FLUSH | REQ_FUA; 1823 + /* 1824 + * And if there is "feature-flush-cache" use that above 1825 + * barriers. 1826 + */ 1827 + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1828 + "feature-flush-cache", "%d", &flush, 1829 + NULL); 1830 + 1831 + if (!err && flush) 1832 + info->feature_flush = REQ_FLUSH; 1833 + 1834 + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1835 + "feature-discard", "%d", &discard, 1836 + NULL); 1837 + 1838 + if (!err && discard) 1839 + blkfront_setup_discard(info); 1840 + 1841 + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1842 + "feature-persistent", "%u", &persistent, 1843 + NULL); 1844 + if (err) 1845 + info->feature_persistent = 0; 1846 + else 1847 + info->feature_persistent = persistent; 1848 + 1849 + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1850 + "feature-max-indirect-segments", "%u", &indirect_segments, 1851 + NULL); 1852 + if (err) 1853 + info->max_indirect_segments = 0; 1854 + else 1855 + info->max_indirect_segments = min(indirect_segments, 1856 + xen_blkif_max_segments); 1857 + 1858 + return blkfront_setup_indirect(info); 1859 + } 1860 + 1861 + /* 1796 1862 * Invoked when the backend is finally 'ready' (and has told produced 1797 1863 * the details about the physical device - #sectors, size, etc). 1798 1864 */ ··· 1865 1807 unsigned int physical_sector_size; 1866 1808 unsigned int binfo; 1867 1809 int err; 1868 - int barrier, flush, discard, persistent; 1869 1810 1870 1811 switch (info->connected) { 1871 1812 case BLKIF_STATE_CONNECTED: ··· 1921 1864 if (err != 1) 1922 1865 physical_sector_size = sector_size; 1923 1866 1924 - info->feature_flush = 0; 1925 - 1926 - err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1927 - "feature-barrier", "%d", &barrier, 1928 - NULL); 1929 - 1930 - /* 1931 - * If there's no "feature-barrier" defined, then it means 1932 - * we're dealing with a very old backend which writes 1933 - * synchronously; nothing to do. 1934 - * 1935 - * If there are barriers, then we use flush. 1936 - */ 1937 - if (!err && barrier) 1938 - info->feature_flush = REQ_FLUSH | REQ_FUA; 1939 - /* 1940 - * And if there is "feature-flush-cache" use that above 1941 - * barriers. 1942 - */ 1943 - err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1944 - "feature-flush-cache", "%d", &flush, 1945 - NULL); 1946 - 1947 - if (!err && flush) 1948 - info->feature_flush = REQ_FLUSH; 1949 - 1950 - err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1951 - "feature-discard", "%d", &discard, 1952 - NULL); 1953 - 1954 - if (!err && discard) 1955 - blkfront_setup_discard(info); 1956 - 1957 - err = xenbus_gather(XBT_NIL, info->xbdev->otherend, 1958 - "feature-persistent", "%u", &persistent, 1959 - NULL); 1960 - if (err) 1961 - info->feature_persistent = 0; 1962 - else 1963 - info->feature_persistent = persistent; 1964 - 1965 - err = blkfront_setup_indirect(info); 1867 + err = blkfront_gather_backend_features(info); 1966 1868 if (err) { 1967 1869 xenbus_dev_fatal(info->xbdev, err, "setup_indirect at %s", 1968 1870 info->xbdev->otherend);