Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3226AC433DB for ; Wed, 6 Jan 2021 17:50:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0B332311B for ; Wed, 6 Jan 2021 17:50:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727429AbhAFRt7 convert rfc822-to-8bit (ORCPT ); Wed, 6 Jan 2021 12:49:59 -0500 Received: from mail.eclipso.de ([217.69.254.104]:49926 "EHLO mail.eclipso.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727323AbhAFRt7 (ORCPT ); Wed, 6 Jan 2021 12:49:59 -0500 Received: from mail.eclipso.de (www1.eclipso.de [217.69.254.102]) by mail.eclipso.de with ESMTP id 7CC49F43 for ; Wed, 06 Jan 2021 18:49:17 +0100 (CET) Date: Wed, 06 Jan 2021 18:49:17 +0100 MIME-Version: 1.0 Message-ID: X-Mailer: eclipso / 7.4.0 From: " " Subject: script to disable writeback when a drive is idle Reply-To: " " To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-bcache@vger.kernel.org Hi all, I have two stacks of a HDD with a bcache SSD in front of it in writeback mode. I have made the following quick and dirty script to disable writeback when the HDD is in standby. I hope it helps somebody: # cat writeback.sh #!/bin/bash function sdbGetState() { hdparmstr=$(hdparm -C /dev/sdb | grep drive) echo $hdparmstr } function sddGetState() { hdparmstr=$(hdparm -C /dev/sdd | grep drive) echo $hdparmstr } strSdb=$(sdbGetState) echo $strSdb strSdd=$(sddGetState) echo $strSdd if [ "$strSdd" = 'drive state is: active/idle' ]; then echo 1 > /sys/block/bcache0/bcache/writeback_running echo active else echo 0 > /sys/block/bcache0/bcache/writeback_running echo idle fi if [ "$strSdb" = 'drive state is: active/idle' ]; then echo 1 > /sys/block/bcache1/bcache/writeback_running echo active else echo 0 > /sys/block/bcache1/bcache/writeback_running echo idle fi --- Take your mailboxes with you. Free, fast and secure Mail & Cloud: https://www.eclipso.eu - Time to change!